idle_notifier: implement v2
This commit is contained in:
parent
0cf547655d
commit
6f5693648a
5 changed files with 53 additions and 23 deletions
|
|
@ -1,5 +1,9 @@
|
|||
# Unreleased
|
||||
|
||||
- Needs jay-config release.
|
||||
- Needs jay-toml-config release.
|
||||
- Needs jay-compositor release.
|
||||
|
||||
# 1.7.0
|
||||
|
||||
- Needs jay-config release.
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ Jay supports the following wayland protocols:
|
|||
| ext_data_control_manager_v1 | 1 | Yes |
|
||||
| ext_foreign_toplevel_image_capture_source_manager_v1 | 1 | |
|
||||
| ext_foreign_toplevel_list_v1 | 1 | Yes |
|
||||
| ext_idle_notifier_v1 | 1 | Yes |
|
||||
| ext_idle_notifier_v1 | 2 | Yes |
|
||||
| ext_image_copy_capture_manager_v1 | 1[^composited] | Yes |
|
||||
| ext_output_image_capture_source_manager_v1 | 1 | |
|
||||
| ext_session_lock_manager_v1 | 1 | Yes |
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
- Add support fo ext-data-control-v1.
|
||||
- Implement wl-fixes.
|
||||
- Implement ei_touchscreen v2.
|
||||
- Implement idle-notification v2.
|
||||
|
||||
# 1.7.0 (2024-10-25)
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use {
|
|||
leaks::Tracker,
|
||||
object::{Object, Version},
|
||||
utils::errorfmt::ErrorFmt,
|
||||
wire::{ext_idle_notifier_v1::*, ExtIdleNotifierV1Id},
|
||||
wire::{ext_idle_notifier_v1::*, ExtIdleNotificationV1Id, ExtIdleNotifierV1Id, WlSeatId},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
thiserror::Error,
|
||||
|
|
@ -46,6 +46,36 @@ pub struct ExtIdleNotifierV1 {
|
|||
pub version: Version,
|
||||
}
|
||||
|
||||
impl ExtIdleNotifierV1 {
|
||||
fn create_notification(
|
||||
&self,
|
||||
id: ExtIdleNotificationV1Id,
|
||||
timeout: u32,
|
||||
seat: WlSeatId,
|
||||
) -> Result<(), ExtIdleNotifierV1Error> {
|
||||
let seat = self.client.lookup(seat)?;
|
||||
let notification = Rc::new(ExtIdleNotificationV1 {
|
||||
id,
|
||||
client: self.client.clone(),
|
||||
tracker: Default::default(),
|
||||
resume: Default::default(),
|
||||
task: Cell::new(None),
|
||||
seat: seat.global.clone(),
|
||||
duration_usec: (timeout as u64).max(1000).saturating_mul(1000),
|
||||
version: self.version,
|
||||
});
|
||||
track!(self.client, notification);
|
||||
self.client.add_client_obj(¬ification)?;
|
||||
let future = self
|
||||
.client
|
||||
.state
|
||||
.eng
|
||||
.spawn("idle notifier", run(notification.clone()));
|
||||
notification.task.set(Some(future));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl ExtIdleNotifierV1RequestHandler for ExtIdleNotifierV1 {
|
||||
type Error = ExtIdleNotifierV1Error;
|
||||
|
||||
|
|
@ -59,26 +89,15 @@ impl ExtIdleNotifierV1RequestHandler for ExtIdleNotifierV1 {
|
|||
req: GetIdleNotification,
|
||||
_slf: &Rc<Self>,
|
||||
) -> Result<(), Self::Error> {
|
||||
let seat = self.client.lookup(req.seat)?;
|
||||
let notification = Rc::new(ExtIdleNotificationV1 {
|
||||
id: req.id,
|
||||
client: self.client.clone(),
|
||||
tracker: Default::default(),
|
||||
resume: Default::default(),
|
||||
task: Cell::new(None),
|
||||
seat: seat.global.clone(),
|
||||
duration_usec: (req.timeout as u64).max(1000).saturating_mul(1000),
|
||||
version: self.version,
|
||||
});
|
||||
track!(self.client, notification);
|
||||
self.client.add_client_obj(¬ification)?;
|
||||
let future = self
|
||||
.client
|
||||
.state
|
||||
.eng
|
||||
.spawn("idle notifier", run(notification.clone()));
|
||||
notification.task.set(Some(future));
|
||||
Ok(())
|
||||
self.create_notification(req.id, req.timeout, req.seat)
|
||||
}
|
||||
|
||||
fn get_input_idle_notification(
|
||||
&self,
|
||||
req: GetInputIdleNotification,
|
||||
_slf: &Rc<Self>,
|
||||
) -> Result<(), Self::Error> {
|
||||
self.create_notification(req.id, req.timeout, req.seat)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -118,7 +137,7 @@ impl Global for ExtIdleNotifierV1Global {
|
|||
}
|
||||
|
||||
fn version(&self) -> u32 {
|
||||
1
|
||||
2
|
||||
}
|
||||
|
||||
fn required_caps(&self) -> ClientCaps {
|
||||
|
|
|
|||
|
|
@ -8,3 +8,9 @@ request get_idle_notification {
|
|||
timeout: u32,
|
||||
seat: id(wl_seat),
|
||||
}
|
||||
|
||||
request get_input_idle_notification {
|
||||
id: id(ext_idle_notification_v1),
|
||||
timeout: u32,
|
||||
seat: id(wl_seat),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue