Merge pull request #186 from mahkoh/drm-lease
wayland: implement wp-drm-lease-v1
This commit is contained in:
commit
fe2663fca3
41 changed files with 1622 additions and 170 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
# Unreleased
|
# Unreleased
|
||||||
|
|
||||||
|
- Needs jay-compositor release.
|
||||||
|
|
||||||
# 1.1.0
|
# 1.1.0
|
||||||
|
|
||||||
- Needs jay-config release.
|
- Needs jay-config release.
|
||||||
|
|
|
||||||
|
|
@ -118,6 +118,10 @@ You can explicitly opt into giving applications access to privileged protocols v
|
||||||
|
|
||||||
Jay's shortcut system allows you to execute an action when a key is pressed and to execute a different action when the key is released.
|
Jay's shortcut system allows you to execute an action when a key is pressed and to execute a different action when the key is released.
|
||||||
|
|
||||||
|
## VR
|
||||||
|
|
||||||
|
Jay's supports leasing VR headsets to applications.
|
||||||
|
|
||||||
## Protocol Support
|
## Protocol Support
|
||||||
|
|
||||||
Jay supports the following wayland protocols:
|
Jay supports the following wayland protocols:
|
||||||
|
|
@ -139,6 +143,7 @@ Jay supports the following wayland protocols:
|
||||||
| wp_alpha_modifier_v1 | 1 | |
|
| wp_alpha_modifier_v1 | 1 | |
|
||||||
| wp_content_type_manager_v1 | 1 | |
|
| wp_content_type_manager_v1 | 1 | |
|
||||||
| wp_cursor_shape_manager_v1 | 1 | |
|
| wp_cursor_shape_manager_v1 | 1 | |
|
||||||
|
| wp_drm_lease_device_v1 | 1 | |
|
||||||
| wp_fractional_scale_manager_v1 | 1 | |
|
| wp_fractional_scale_manager_v1 | 1 | |
|
||||||
| wp_linux_drm_syncobj_manager_v1 | 1 | |
|
| wp_linux_drm_syncobj_manager_v1 | 1 | |
|
||||||
| wp_presentation | 1 | |
|
| wp_presentation | 1 | |
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
- Add support for wp-security-manager-v1.
|
- Add support for wp-security-manager-v1.
|
||||||
- Add support for xdg-dialog-v1.
|
- Add support for xdg-dialog-v1.
|
||||||
- Add support for ext-transient-seat-v1.
|
- Add support for ext-transient-seat-v1.
|
||||||
|
- Add support for wp-drm-lease-v1.
|
||||||
|
|
||||||
# 1.1.0 (2024-04-22)
|
# 1.1.0 (2024-04-22)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
async_engine::SpawnedFuture,
|
async_engine::SpawnedFuture,
|
||||||
client::{ClientCaps, CAP_LAYER_SHELL},
|
client::{ClientCaps, CAPS_DEFAULT},
|
||||||
state::State,
|
state::State,
|
||||||
utils::{errorfmt::ErrorFmt, oserror::OsError, xrd::xrd},
|
utils::{errorfmt::ErrorFmt, oserror::OsError, xrd::xrd},
|
||||||
},
|
},
|
||||||
|
|
@ -154,7 +154,7 @@ impl Acceptor {
|
||||||
state.eng.spawn(accept(
|
state.eng.spawn(accept(
|
||||||
acc.socket.insecure.clone(),
|
acc.socket.insecure.clone(),
|
||||||
state.clone(),
|
state.clone(),
|
||||||
CAP_LAYER_SHELL,
|
CAPS_DEFAULT,
|
||||||
)),
|
)),
|
||||||
];
|
];
|
||||||
state.acceptor.set(Some(acc.clone()));
|
state.acceptor.set(Some(acc.clone()));
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use {
|
||||||
gfx_api::{GfxFramebuffer, SyncFile},
|
gfx_api::{GfxFramebuffer, SyncFile},
|
||||||
ifs::wl_seat::wl_pointer::{CONTINUOUS, FINGER, HORIZONTAL_SCROLL, VERTICAL_SCROLL, WHEEL},
|
ifs::wl_seat::wl_pointer::{CONTINUOUS, FINGER, HORIZONTAL_SCROLL, VERTICAL_SCROLL, WHEEL},
|
||||||
libinput::consts::DeviceCapability,
|
libinput::consts::DeviceCapability,
|
||||||
video::drm::{ConnectorType, DrmError, DrmVersion},
|
video::drm::{ConnectorType, DrmConnector, DrmError, DrmVersion},
|
||||||
},
|
},
|
||||||
jay_config::video::GfxApi,
|
jay_config::video::GfxApi,
|
||||||
std::{
|
std::{
|
||||||
|
|
@ -15,7 +15,7 @@ use {
|
||||||
fmt::{Debug, Display, Formatter},
|
fmt::{Debug, Display, Formatter},
|
||||||
rc::Rc,
|
rc::Rc,
|
||||||
},
|
},
|
||||||
uapi::c,
|
uapi::{c, OwnedFd},
|
||||||
};
|
};
|
||||||
|
|
||||||
linear_ids!(ConnectorIds, ConnectorId);
|
linear_ids!(ConnectorIds, ConnectorId);
|
||||||
|
|
@ -59,6 +59,7 @@ pub struct MonitorInfo {
|
||||||
pub initial_mode: Mode,
|
pub initial_mode: Mode,
|
||||||
pub width_mm: i32,
|
pub width_mm: i32,
|
||||||
pub height_mm: i32,
|
pub height_mm: i32,
|
||||||
|
pub non_desktop: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
|
|
@ -90,6 +91,12 @@ pub trait Connector {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
fn set_mode(&self, mode: Mode);
|
fn set_mode(&self, mode: Mode);
|
||||||
|
fn set_non_desktop_override(&self, non_desktop: Option<bool>) {
|
||||||
|
let _ = non_desktop;
|
||||||
|
}
|
||||||
|
fn drm_object_id(&self) -> Option<DrmConnector> {
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
@ -99,6 +106,8 @@ pub enum ConnectorEvent {
|
||||||
Disconnected,
|
Disconnected,
|
||||||
Removed,
|
Removed,
|
||||||
ModeChanged(Mode),
|
ModeChanged(Mode),
|
||||||
|
Unavailable,
|
||||||
|
Available,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait HardwareCursor: Debug {
|
pub trait HardwareCursor: Debug {
|
||||||
|
|
@ -282,4 +291,20 @@ pub trait BackendDrmDevice {
|
||||||
fn version(&self) -> Result<DrmVersion, DrmError>;
|
fn version(&self) -> Result<DrmVersion, DrmError>;
|
||||||
fn set_direct_scanout_enabled(&self, enabled: bool);
|
fn set_direct_scanout_enabled(&self, enabled: bool);
|
||||||
fn is_render_device(&self) -> bool;
|
fn is_render_device(&self) -> bool;
|
||||||
|
fn create_lease(
|
||||||
|
self: Rc<Self>,
|
||||||
|
lessee: Rc<dyn BackendDrmLessee>,
|
||||||
|
connector_ids: &[ConnectorId],
|
||||||
|
) {
|
||||||
|
let _ = lessee;
|
||||||
|
let _ = connector_ids;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait BackendDrmLease {
|
||||||
|
fn fd(&self) -> &Rc<OwnedFd>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait BackendDrmLessee {
|
||||||
|
fn created(&self, lease: Rc<dyn BackendDrmLease>);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,15 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
backend::BackendEvent,
|
backend::{BackendEvent, ConnectorEvent},
|
||||||
backends::metal::{
|
backends::metal::{
|
||||||
video::{MetalDrmDeviceData, PendingDrmDevice},
|
video::{FrontState, MetalDrmDeviceData, PendingDrmDevice},
|
||||||
MetalBackend, MetalDevice, MetalError, MetalInputDevice,
|
MetalBackend, MetalDevice, MetalError, MetalInputDevice,
|
||||||
},
|
},
|
||||||
dbus::{DbusError, TRUE},
|
dbus::{DbusError, TRUE},
|
||||||
udev::UdevDevice,
|
udev::UdevDevice,
|
||||||
utils::{bitflags::BitflagsExt, errorfmt::ErrorFmt, nonblock::set_nonblock},
|
utils::{
|
||||||
|
bitflags::BitflagsExt, cell_ext::CellExt, errorfmt::ErrorFmt, nonblock::set_nonblock,
|
||||||
|
},
|
||||||
video::drm::DrmMaster,
|
video::drm::DrmMaster,
|
||||||
wire_dbus::org::freedesktop::login1::session::{
|
wire_dbus::org::freedesktop::login1::session::{
|
||||||
PauseDevice, ResumeDevice, TakeDeviceReply,
|
PauseDevice, ResumeDevice, TakeDeviceReply,
|
||||||
|
|
@ -89,6 +91,18 @@ impl MetalBackend {
|
||||||
|
|
||||||
fn handle_drm_device_resume(self: &Rc<Self>, dev: &Rc<MetalDrmDeviceData>, _fd: Rc<OwnedFd>) {
|
fn handle_drm_device_resume(self: &Rc<Self>, dev: &Rc<MetalDrmDeviceData>, _fd: Rc<OwnedFd>) {
|
||||||
log::info!("Device resumed: {}", dev.dev.devnode.to_bytes().as_bstr());
|
log::info!("Device resumed: {}", dev.dev.devnode.to_bytes().as_bstr());
|
||||||
|
dev.dev.paused.set(false);
|
||||||
|
self.break_leases(dev);
|
||||||
|
for c in dev.connectors.lock().values() {
|
||||||
|
match c.frontend_state.get() {
|
||||||
|
FrontState::Removed | FrontState::Disconnected | FrontState::Connected { .. } => {}
|
||||||
|
FrontState::Unavailable => {
|
||||||
|
if c.lease.is_none() {
|
||||||
|
c.send_event(ConnectorEvent::Available);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if let Err(e) = self.resume_drm_device(dev) {
|
if let Err(e) = self.resume_drm_device(dev) {
|
||||||
log::error!("Could not resume drm device: {}", ErrorFmt(e));
|
log::error!("Could not resume drm device: {}", ErrorFmt(e));
|
||||||
}
|
}
|
||||||
|
|
@ -149,6 +163,21 @@ impl MetalBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_drm_device_paused(self: &Rc<Self>, dev: &Rc<MetalDrmDeviceData>) {
|
fn handle_drm_device_paused(self: &Rc<Self>, dev: &Rc<MetalDrmDeviceData>) {
|
||||||
|
dev.dev.paused.set(true);
|
||||||
|
for c in dev.connectors.lock().values() {
|
||||||
|
match c.frontend_state.get() {
|
||||||
|
FrontState::Removed
|
||||||
|
| FrontState::Disconnected
|
||||||
|
| FrontState::Unavailable
|
||||||
|
| FrontState::Connected { non_desktop: false } => {}
|
||||||
|
FrontState::Connected { non_desktop: true } => {
|
||||||
|
c.send_event(ConnectorEvent::Unavailable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (lease_id, lease) in dev.dev.leases.lock().drain() {
|
||||||
|
dev.dev.leases_to_break.set(lease_id, lease);
|
||||||
|
}
|
||||||
log::info!("Device paused: {}", dev.dev.devnode.to_bytes().as_bstr());
|
log::info!("Device paused: {}", dev.dev.devnode.to_bytes().as_bstr());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,9 @@ use {
|
||||||
crate::{
|
crate::{
|
||||||
async_engine::{Phase, SpawnedFuture},
|
async_engine::{Phase, SpawnedFuture},
|
||||||
backend::{
|
backend::{
|
||||||
BackendDrmDevice, BackendEvent, Connector, ConnectorEvent, ConnectorId,
|
BackendDrmDevice, BackendDrmLease, BackendDrmLessee, BackendEvent, Connector,
|
||||||
ConnectorKernelId, DrmDeviceId, HardwareCursor, Mode, MonitorInfo,
|
ConnectorEvent, ConnectorId, ConnectorKernelId, DrmDeviceId, HardwareCursor, Mode,
|
||||||
|
MonitorInfo,
|
||||||
},
|
},
|
||||||
backends::metal::{MetalBackend, MetalError},
|
backends::metal::{MetalBackend, MetalError},
|
||||||
drm_feedback::DrmFeedback,
|
drm_feedback::DrmFeedback,
|
||||||
|
|
@ -20,7 +21,7 @@ use {
|
||||||
tree::OutputNode,
|
tree::OutputNode,
|
||||||
udev::UdevDevice,
|
udev::UdevDevice,
|
||||||
utils::{
|
utils::{
|
||||||
asyncevent::AsyncEvent, bitflags::BitflagsExt, clonecell::CloneCell,
|
asyncevent::AsyncEvent, bitflags::BitflagsExt, cell_ext::CellExt, clonecell::CloneCell,
|
||||||
copyhashmap::CopyHashMap, debug_fn::debug_fn, errorfmt::ErrorFmt, numcell::NumCell,
|
copyhashmap::CopyHashMap, debug_fn::debug_fn, errorfmt::ErrorFmt, numcell::NumCell,
|
||||||
on_change::OnChange, opaque_cell::OpaqueCell, oserror::OsError,
|
on_change::OnChange, opaque_cell::OpaqueCell, oserror::OsError,
|
||||||
transform_ext::TransformExt,
|
transform_ext::TransformExt,
|
||||||
|
|
@ -29,10 +30,10 @@ use {
|
||||||
dmabuf::DmaBufId,
|
dmabuf::DmaBufId,
|
||||||
drm::{
|
drm::{
|
||||||
drm_mode_modeinfo, Change, ConnectorStatus, ConnectorType, DrmBlob, DrmConnector,
|
drm_mode_modeinfo, Change, ConnectorStatus, ConnectorType, DrmBlob, DrmConnector,
|
||||||
DrmCrtc, DrmEncoder, DrmError, DrmEvent, DrmFramebuffer, DrmMaster, DrmModeInfo,
|
DrmCrtc, DrmEncoder, DrmError, DrmEvent, DrmFramebuffer, DrmLease, DrmMaster,
|
||||||
DrmObject, DrmPlane, DrmProperty, DrmPropertyDefinition, DrmPropertyType,
|
DrmModeInfo, DrmObject, DrmPlane, DrmProperty, DrmPropertyDefinition,
|
||||||
DrmVersion, PropBlob, DRM_CLIENT_CAP_ATOMIC, DRM_MODE_ATOMIC_ALLOW_MODESET,
|
DrmPropertyType, DrmVersion, PropBlob, DRM_CLIENT_CAP_ATOMIC,
|
||||||
DRM_MODE_ATOMIC_NONBLOCK, DRM_MODE_PAGE_FLIP_EVENT,
|
DRM_MODE_ATOMIC_ALLOW_MODESET, DRM_MODE_ATOMIC_NONBLOCK, DRM_MODE_PAGE_FLIP_EVENT,
|
||||||
},
|
},
|
||||||
gbm::{GbmDevice, GBM_BO_USE_LINEAR, GBM_BO_USE_RENDERING, GBM_BO_USE_SCANOUT},
|
gbm::{GbmDevice, GBM_BO_USE_LINEAR, GBM_BO_USE_RENDERING, GBM_BO_USE_SCANOUT},
|
||||||
Modifier, INVALID_MODIFIER,
|
Modifier, INVALID_MODIFIER,
|
||||||
|
|
@ -42,17 +43,22 @@ use {
|
||||||
arrayvec::ArrayVec,
|
arrayvec::ArrayVec,
|
||||||
bstr::{BString, ByteSlice},
|
bstr::{BString, ByteSlice},
|
||||||
indexmap::{indexset, IndexSet},
|
indexmap::{indexset, IndexSet},
|
||||||
|
isnt::std_1::collections::IsntHashMap2Ext,
|
||||||
jay_config::video::GfxApi,
|
jay_config::video::GfxApi,
|
||||||
std::{
|
std::{
|
||||||
any::Any,
|
any::Any,
|
||||||
cell::{Cell, RefCell},
|
cell::{Cell, RefCell},
|
||||||
|
collections::hash_map::Entry,
|
||||||
ffi::CString,
|
ffi::CString,
|
||||||
fmt::{Debug, Formatter},
|
fmt::{Debug, Formatter},
|
||||||
mem,
|
mem,
|
||||||
ops::DerefMut,
|
ops::DerefMut,
|
||||||
rc::{Rc, Weak},
|
rc::{Rc, Weak},
|
||||||
},
|
},
|
||||||
uapi::c::{self, dev_t},
|
uapi::{
|
||||||
|
c::{self, dev_t},
|
||||||
|
OwnedFd,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct PendingDrmDevice {
|
pub struct PendingDrmDevice {
|
||||||
|
|
@ -67,7 +73,6 @@ pub struct MetalRenderContext {
|
||||||
pub gfx: Rc<dyn GfxContext>,
|
pub gfx: Rc<dyn GfxContext>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct MetalDrmDevice {
|
pub struct MetalDrmDevice {
|
||||||
pub backend: Rc<MetalBackend>,
|
pub backend: Rc<MetalBackend>,
|
||||||
pub id: DrmDeviceId,
|
pub id: DrmDeviceId,
|
||||||
|
|
@ -89,6 +94,16 @@ pub struct MetalDrmDevice {
|
||||||
pub on_change: OnChange<crate::backend::DrmEvent>,
|
pub on_change: OnChange<crate::backend::DrmEvent>,
|
||||||
pub direct_scanout_enabled: Cell<Option<bool>>,
|
pub direct_scanout_enabled: Cell<Option<bool>>,
|
||||||
pub is_nvidia: bool,
|
pub is_nvidia: bool,
|
||||||
|
pub lease_ids: MetalLeaseIds,
|
||||||
|
pub leases: CopyHashMap<MetalLeaseId, MetalLeaseData>,
|
||||||
|
pub leases_to_break: CopyHashMap<MetalLeaseId, MetalLeaseData>,
|
||||||
|
pub paused: Cell<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Debug for MetalDrmDevice {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.debug_struct("MetalDrmDevice").finish_non_exhaustive()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MetalDrmDevice {
|
impl MetalDrmDevice {
|
||||||
|
|
@ -140,6 +155,120 @@ impl BackendDrmDevice for MetalDrmDevice {
|
||||||
fn is_render_device(&self) -> bool {
|
fn is_render_device(&self) -> bool {
|
||||||
Some(self.id) == self.backend.ctx.get().map(|c| c.dev_id)
|
Some(self.id) == self.backend.ctx.get().map(|c| c.dev_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn create_lease(
|
||||||
|
self: Rc<Self>,
|
||||||
|
lessee: Rc<dyn BackendDrmLessee>,
|
||||||
|
connector_ids: &[ConnectorId],
|
||||||
|
) {
|
||||||
|
let Some(data) = self.backend.device_holder.drm_devices.get(&self.devnum) else {
|
||||||
|
log::error!("Tried to create a lease for a DRM device that no longer exists");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let mut connectors = vec![];
|
||||||
|
let mut crtcs = AHashMap::new();
|
||||||
|
let mut planes = AHashMap::new();
|
||||||
|
let mut ids = vec![];
|
||||||
|
for id in connector_ids {
|
||||||
|
let Some(connector) = data
|
||||||
|
.connectors
|
||||||
|
.lock()
|
||||||
|
.values()
|
||||||
|
.find(|c| c.connector_id == *id)
|
||||||
|
.cloned()
|
||||||
|
else {
|
||||||
|
log::error!("Tried to lease connector {id} but no such connector exists");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let fe_state = connector.frontend_state.get();
|
||||||
|
match fe_state {
|
||||||
|
FrontState::Connected { non_desktop: true } => {}
|
||||||
|
FrontState::Connected { non_desktop: false }
|
||||||
|
| FrontState::Removed
|
||||||
|
| FrontState::Disconnected
|
||||||
|
| FrontState::Unavailable => {
|
||||||
|
log::error!(
|
||||||
|
"Tried to lease connector {id} but it is in an invalid state: {fe_state:?}"
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if let Some(lease_id) = connector.lease.get() {
|
||||||
|
match data.dev.leases_to_break.lock().entry(lease_id) {
|
||||||
|
Entry::Occupied(oe) => {
|
||||||
|
if oe.get().try_revoke() {
|
||||||
|
oe.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
log::error!("Connector is logically available for leasing, has a lease ID, and has no entry in leases_to_break");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if connector.lease.is_some() {
|
||||||
|
log::error!("Tried to lease connector {id} but it is already leased");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let dd = &*connector.display.borrow();
|
||||||
|
let crtc = dd.crtcs.values().find(|c| {
|
||||||
|
c.connector.is_none() && c.lease.is_none() && crtcs.not_contains_key(&c.id)
|
||||||
|
});
|
||||||
|
let Some(crtc) = crtc else {
|
||||||
|
log::error!("Tried to lease connector {id} but it has no matching unused CRTC");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let plane = crtc.possible_planes.values().find(|p| {
|
||||||
|
!p.assigned.get()
|
||||||
|
&& p.lease.is_none()
|
||||||
|
&& planes.not_contains_key(&p.id)
|
||||||
|
&& p.ty == PlaneType::Primary
|
||||||
|
});
|
||||||
|
let Some(plane) = plane else {
|
||||||
|
log::error!("Tried to lease connector {id} but it has no matching unused plane");
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
connectors.push(connector.clone());
|
||||||
|
crtcs.insert(crtc.id, crtc.clone());
|
||||||
|
planes.insert(plane.id, plane.clone());
|
||||||
|
ids.push(connector.id.0);
|
||||||
|
ids.push(crtc.id.0);
|
||||||
|
ids.push(plane.id.0);
|
||||||
|
}
|
||||||
|
let drm_lease = match self.master.lease(&ids) {
|
||||||
|
Ok(l) => l,
|
||||||
|
Err(e) => {
|
||||||
|
log::error!("Could not create lease: {}", ErrorFmt(e));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let lease_id = self.lease_ids.next();
|
||||||
|
for c in &connectors {
|
||||||
|
c.lease.set(Some(lease_id));
|
||||||
|
c.send_event(ConnectorEvent::Unavailable);
|
||||||
|
}
|
||||||
|
for c in crtcs.values() {
|
||||||
|
c.lease.set(Some(lease_id));
|
||||||
|
}
|
||||||
|
for p in planes.values() {
|
||||||
|
p.lease.set(Some(lease_id));
|
||||||
|
}
|
||||||
|
let fd = drm_lease.lessee_fd().clone();
|
||||||
|
let lease_data = MetalLeaseData {
|
||||||
|
lease: drm_lease,
|
||||||
|
_lessee: lessee.clone(),
|
||||||
|
connectors,
|
||||||
|
crtcs: crtcs.values().cloned().collect(),
|
||||||
|
planes: planes.values().cloned().collect(),
|
||||||
|
revoked: Cell::new(false),
|
||||||
|
};
|
||||||
|
self.leases.set(lease_id, lease_data);
|
||||||
|
let lease = Rc::new(MetalLease {
|
||||||
|
dev: self.clone(),
|
||||||
|
id: lease_id,
|
||||||
|
fd,
|
||||||
|
});
|
||||||
|
lessee.created(lease);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct HandleEvents {
|
pub struct HandleEvents {
|
||||||
|
|
@ -167,6 +296,8 @@ pub struct ConnectorDisplayData {
|
||||||
pub modes: Vec<DrmModeInfo>,
|
pub modes: Vec<DrmModeInfo>,
|
||||||
pub mode: Option<DrmModeInfo>,
|
pub mode: Option<DrmModeInfo>,
|
||||||
pub refresh: u32,
|
pub refresh: u32,
|
||||||
|
pub non_desktop: bool,
|
||||||
|
pub non_desktop_effective: bool,
|
||||||
|
|
||||||
pub monitor_manufacturer: String,
|
pub monitor_manufacturer: String,
|
||||||
pub monitor_name: String,
|
pub monitor_name: String,
|
||||||
|
|
@ -189,7 +320,81 @@ impl ConnectorDisplayData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
linear_ids!(MetalLeaseIds, MetalLeaseId, u64);
|
||||||
|
|
||||||
|
pub struct MetalLeaseData {
|
||||||
|
lease: DrmLease,
|
||||||
|
_lessee: Rc<dyn BackendDrmLessee>,
|
||||||
|
connectors: Vec<Rc<MetalConnector>>,
|
||||||
|
crtcs: Vec<Rc<MetalCrtc>>,
|
||||||
|
planes: Vec<Rc<MetalPlane>>,
|
||||||
|
revoked: Cell<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MetalLeaseData {
|
||||||
|
fn try_revoke(&self) -> bool {
|
||||||
|
if self.revoked.get() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
let res = self.lease.try_revoke();
|
||||||
|
if res {
|
||||||
|
self.revoked.set(res);
|
||||||
|
for c in &self.connectors {
|
||||||
|
c.lease.take();
|
||||||
|
}
|
||||||
|
for c in &self.crtcs {
|
||||||
|
c.lease.take();
|
||||||
|
}
|
||||||
|
for p in &self.planes {
|
||||||
|
p.lease.take();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct MetalLease {
|
||||||
|
dev: Rc<MetalDrmDevice>,
|
||||||
|
id: MetalLeaseId,
|
||||||
|
fd: Rc<OwnedFd>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Drop for MetalLease {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
if let Some(lease) = self.dev.leases.remove(&self.id) {
|
||||||
|
if !self.dev.paused.get() {
|
||||||
|
for c in &lease.connectors {
|
||||||
|
match c.frontend_state.get() {
|
||||||
|
FrontState::Removed
|
||||||
|
| FrontState::Disconnected
|
||||||
|
| FrontState::Connected { .. } => {}
|
||||||
|
FrontState::Unavailable => {
|
||||||
|
c.send_event(ConnectorEvent::Available);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !lease.try_revoke() {
|
||||||
|
self.dev.leases_to_break.set(self.id, lease);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BackendDrmLease for MetalLease {
|
||||||
|
fn fd(&self) -> &Rc<OwnedFd> {
|
||||||
|
&self.fd
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||||
|
pub enum FrontState {
|
||||||
|
Removed,
|
||||||
|
Disconnected,
|
||||||
|
Connected { non_desktop: bool },
|
||||||
|
Unavailable,
|
||||||
|
}
|
||||||
|
|
||||||
pub struct MetalConnector {
|
pub struct MetalConnector {
|
||||||
pub id: DrmConnector,
|
pub id: DrmConnector,
|
||||||
pub master: Rc<DrmMaster>,
|
pub master: Rc<DrmMaster>,
|
||||||
|
|
@ -204,6 +409,9 @@ pub struct MetalConnector {
|
||||||
pub next_buffer: NumCell<usize>,
|
pub next_buffer: NumCell<usize>,
|
||||||
|
|
||||||
pub enabled: Cell<bool>,
|
pub enabled: Cell<bool>,
|
||||||
|
pub non_desktop_override: Cell<Option<bool>>,
|
||||||
|
|
||||||
|
pub lease: Cell<Option<MetalLeaseId>>,
|
||||||
|
|
||||||
pub can_present: Cell<bool>,
|
pub can_present: Cell<bool>,
|
||||||
pub has_damage: Cell<bool>,
|
pub has_damage: Cell<bool>,
|
||||||
|
|
@ -211,7 +419,7 @@ pub struct MetalConnector {
|
||||||
|
|
||||||
pub display: RefCell<ConnectorDisplayData>,
|
pub display: RefCell<ConnectorDisplayData>,
|
||||||
|
|
||||||
pub connect_sent: Cell<bool>,
|
pub frontend_state: Cell<FrontState>,
|
||||||
|
|
||||||
pub primary_plane: CloneCell<Option<Rc<MetalPlane>>>,
|
pub primary_plane: CloneCell<Option<Rc<MetalPlane>>>,
|
||||||
pub cursor_plane: CloneCell<Option<Rc<MetalPlane>>>,
|
pub cursor_plane: CloneCell<Option<Rc<MetalPlane>>>,
|
||||||
|
|
@ -240,7 +448,12 @@ pub struct MetalConnector {
|
||||||
pub direct_scanout_active: Cell<bool>,
|
pub direct_scanout_active: Cell<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
impl Debug for MetalConnector {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.debug_struct("MetalConnnector").finish_non_exhaustive()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub struct MetalHardwareCursor {
|
pub struct MetalHardwareCursor {
|
||||||
pub generation: u64,
|
pub generation: u64,
|
||||||
pub connector: Rc<MetalConnector>,
|
pub connector: Rc<MetalConnector>,
|
||||||
|
|
@ -253,6 +466,13 @@ pub struct MetalHardwareCursor {
|
||||||
pub have_changes: Cell<bool>,
|
pub have_changes: Cell<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Debug for MetalHardwareCursor {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.debug_struct("MetalHardwareCursor")
|
||||||
|
.finish_non_exhaustive()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl HardwareCursor for MetalHardwareCursor {
|
impl HardwareCursor for MetalHardwareCursor {
|
||||||
fn set_enabled(&self, enabled: bool) {
|
fn set_enabled(&self, enabled: bool) {
|
||||||
if self.cursor_enabled_pending.replace(enabled) != enabled {
|
if self.cursor_enabled_pending.replace(enabled) != enabled {
|
||||||
|
|
@ -368,8 +588,12 @@ impl MetalConnector {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_hardware_cursor(self: &Rc<Self>) {
|
fn send_hardware_cursor(self: &Rc<Self>) {
|
||||||
if !self.connect_sent.get() {
|
match self.frontend_state.get() {
|
||||||
return;
|
FrontState::Removed
|
||||||
|
| FrontState::Disconnected
|
||||||
|
| FrontState::Unavailable
|
||||||
|
| FrontState::Connected { non_desktop: true } => return,
|
||||||
|
FrontState::Connected { non_desktop: false } => {}
|
||||||
}
|
}
|
||||||
let generation = self.cursor_generation.fetch_add(1) + 1;
|
let generation = self.cursor_generation.fetch_add(1) + 1;
|
||||||
let hc = match self.cursor_buffers.get() {
|
let hc = match self.cursor_buffers.get() {
|
||||||
|
|
@ -392,9 +616,7 @@ impl MetalConnector {
|
||||||
|
|
||||||
fn connected(&self) -> bool {
|
fn connected(&self) -> bool {
|
||||||
let dd = self.display.borrow_mut();
|
let dd = self.display.borrow_mut();
|
||||||
self.enabled.get()
|
self.enabled.get() && dd.connection == ConnectorStatus::Connected
|
||||||
&& dd.connection == ConnectorStatus::Connected
|
|
||||||
&& self.primary_plane.is_some()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn schedule_present(&self) {
|
pub fn schedule_present(&self) {
|
||||||
|
|
@ -835,6 +1057,78 @@ impl MetalConnector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn send_event(&self, event: ConnectorEvent) {
|
||||||
|
let state = self.frontend_state.get();
|
||||||
|
match &event {
|
||||||
|
ConnectorEvent::Connected(ty) => match state {
|
||||||
|
FrontState::Disconnected => {
|
||||||
|
let non_desktop = ty.non_desktop;
|
||||||
|
self.on_change.send_event(event);
|
||||||
|
self.frontend_state
|
||||||
|
.set(FrontState::Connected { non_desktop });
|
||||||
|
}
|
||||||
|
FrontState::Removed | FrontState::Connected { .. } | FrontState::Unavailable => {
|
||||||
|
log::error!("Tried to send connected event in invalid state: {state:?}");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ConnectorEvent::HardwareCursor(_) | ConnectorEvent::ModeChanged(_) => match state {
|
||||||
|
FrontState::Connected { non_desktop: false } => {
|
||||||
|
self.on_change.send_event(event);
|
||||||
|
}
|
||||||
|
FrontState::Connected { non_desktop: true }
|
||||||
|
| FrontState::Removed
|
||||||
|
| FrontState::Disconnected
|
||||||
|
| FrontState::Unavailable => {
|
||||||
|
let name = match &event {
|
||||||
|
ConnectorEvent::HardwareCursor(_) => "hardware cursor",
|
||||||
|
_ => "mode change",
|
||||||
|
};
|
||||||
|
log::error!("Tried to send {name} event in invalid state: {state:?}");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ConnectorEvent::Disconnected => match state {
|
||||||
|
FrontState::Connected { .. } | FrontState::Unavailable => {
|
||||||
|
self.on_change.send_event(event);
|
||||||
|
self.frontend_state.set(FrontState::Disconnected);
|
||||||
|
}
|
||||||
|
FrontState::Removed | FrontState::Disconnected => {
|
||||||
|
log::error!("Tried to send disconnected event in invalid state: {state:?}");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ConnectorEvent::Removed => match state {
|
||||||
|
FrontState::Disconnected => {
|
||||||
|
self.on_change.send_event(event);
|
||||||
|
self.frontend_state.set(FrontState::Removed);
|
||||||
|
}
|
||||||
|
FrontState::Removed | FrontState::Connected { .. } | FrontState::Unavailable => {
|
||||||
|
log::error!("Tried to send removed event in invalid state: {state:?}");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ConnectorEvent::Unavailable => match state {
|
||||||
|
FrontState::Connected { non_desktop: true } => {
|
||||||
|
self.on_change.send_event(event);
|
||||||
|
self.frontend_state.set(FrontState::Unavailable);
|
||||||
|
}
|
||||||
|
FrontState::Connected { non_desktop: false }
|
||||||
|
| FrontState::Removed
|
||||||
|
| FrontState::Disconnected
|
||||||
|
| FrontState::Unavailable => {
|
||||||
|
log::error!("Tried to send unavailable event in invalid state: {state:?}");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ConnectorEvent::Available => match state {
|
||||||
|
FrontState::Unavailable => {
|
||||||
|
self.on_change.send_event(event);
|
||||||
|
self.frontend_state
|
||||||
|
.set(FrontState::Connected { non_desktop: true });
|
||||||
|
}
|
||||||
|
FrontState::Connected { .. } | FrontState::Removed | FrontState::Disconnected => {
|
||||||
|
log::error!("Tried to send available event in invalid state: {state:?}");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Connector for MetalConnector {
|
impl Connector for MetalConnector {
|
||||||
|
|
@ -891,6 +1185,13 @@ impl Connector for MetalConnector {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_mode(&self, be_mode: Mode) {
|
fn set_mode(&self, be_mode: Mode) {
|
||||||
|
match self.frontend_state.get() {
|
||||||
|
FrontState::Connected { non_desktop: false } => {}
|
||||||
|
FrontState::Connected { non_desktop: true }
|
||||||
|
| FrontState::Removed
|
||||||
|
| FrontState::Disconnected
|
||||||
|
| FrontState::Unavailable => return,
|
||||||
|
}
|
||||||
let mut dd = self.display.borrow_mut();
|
let mut dd = self.display.borrow_mut();
|
||||||
let Some(mode) = dd.modes.iter().find(|m| m.to_backend() == be_mode) else {
|
let Some(mode) = dd.modes.iter().find(|m| m.to_backend() == be_mode) else {
|
||||||
log::warn!("Connector does not support mode {:?}", be_mode);
|
log::warn!("Connector does not support mode {:?}", be_mode);
|
||||||
|
|
@ -912,8 +1213,7 @@ impl Connector for MetalConnector {
|
||||||
dd.mode = Some(mode.clone());
|
dd.mode = Some(mode.clone());
|
||||||
drop(dd);
|
drop(dd);
|
||||||
let Err(e) = self.backend.handle_drm_change_(&dev, true) else {
|
let Err(e) = self.backend.handle_drm_change_(&dev, true) else {
|
||||||
self.on_change
|
self.send_event(ConnectorEvent::ModeChanged(be_mode));
|
||||||
.send_event(ConnectorEvent::ModeChanged(be_mode));
|
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
log::warn!("Could not change mode: {}", ErrorFmt(&e));
|
log::warn!("Could not change mode: {}", ErrorFmt(&e));
|
||||||
|
|
@ -927,14 +1227,38 @@ impl Connector for MetalConnector {
|
||||||
log::warn!("Could not restore the previous mode: {}", ErrorFmt(e));
|
log::warn!("Could not restore the previous mode: {}", ErrorFmt(e));
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_non_desktop_override(&self, non_desktop: Option<bool>) {
|
||||||
|
if self.non_desktop_override.replace(non_desktop) == non_desktop {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let mut dd = self.display.borrow_mut();
|
||||||
|
let non_desktop_effective = non_desktop.unwrap_or(dd.non_desktop);
|
||||||
|
if dd.non_desktop_effective == non_desktop_effective {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
dd.non_desktop_effective = non_desktop_effective;
|
||||||
|
drop(dd);
|
||||||
|
if let Some(dev) = self.backend.device_holder.drm_devices.get(&self.dev.devnum) {
|
||||||
|
if let Err(e) = self.backend.handle_drm_change_(&dev, true) {
|
||||||
|
dev.unprocessed_change.set(true);
|
||||||
|
log::error!("Could not override non-desktop setting: {}", ErrorFmt(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn drm_object_id(&self) -> Option<DrmConnector> {
|
||||||
|
Some(self.id)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct MetalCrtc {
|
pub struct MetalCrtc {
|
||||||
pub id: DrmCrtc,
|
pub id: DrmCrtc,
|
||||||
pub idx: usize,
|
pub idx: usize,
|
||||||
pub master: Rc<DrmMaster>,
|
pub master: Rc<DrmMaster>,
|
||||||
|
|
||||||
|
pub lease: Cell<Option<MetalLeaseId>>,
|
||||||
|
|
||||||
pub possible_planes: AHashMap<DrmPlane, Rc<MetalPlane>>,
|
pub possible_planes: AHashMap<DrmPlane, Rc<MetalPlane>>,
|
||||||
|
|
||||||
pub connector: CloneCell<Option<Rc<MetalConnector>>>,
|
pub connector: CloneCell<Option<Rc<MetalConnector>>>,
|
||||||
|
|
@ -946,6 +1270,12 @@ pub struct MetalCrtc {
|
||||||
pub mode_blob: CloneCell<Option<Rc<PropBlob>>>,
|
pub mode_blob: CloneCell<Option<Rc<PropBlob>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Debug for MetalCrtc {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.debug_struct("MetalCrtc").finish_non_exhaustive()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct MetalEncoder {
|
pub struct MetalEncoder {
|
||||||
pub id: DrmEncoder,
|
pub id: DrmEncoder,
|
||||||
|
|
@ -965,7 +1295,6 @@ pub struct PlaneFormat {
|
||||||
modifiers: IndexSet<Modifier>,
|
modifiers: IndexSet<Modifier>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct MetalPlane {
|
pub struct MetalPlane {
|
||||||
pub id: DrmPlane,
|
pub id: DrmPlane,
|
||||||
pub master: Rc<DrmMaster>,
|
pub master: Rc<DrmMaster>,
|
||||||
|
|
@ -975,6 +1304,7 @@ pub struct MetalPlane {
|
||||||
pub possible_crtcs: u32,
|
pub possible_crtcs: u32,
|
||||||
pub formats: AHashMap<u32, PlaneFormat>,
|
pub formats: AHashMap<u32, PlaneFormat>,
|
||||||
|
|
||||||
|
pub lease: Cell<Option<MetalLeaseId>>,
|
||||||
pub assigned: Cell<bool>,
|
pub assigned: Cell<bool>,
|
||||||
|
|
||||||
pub mode_w: Cell<i32>,
|
pub mode_w: Cell<i32>,
|
||||||
|
|
@ -993,6 +1323,12 @@ pub struct MetalPlane {
|
||||||
pub fb_id: DrmProperty,
|
pub fb_id: DrmProperty,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Debug for MetalPlane {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
f.debug_struct("MetalPlane").finish_non_exhaustive()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn get_connectors(
|
fn get_connectors(
|
||||||
backend: &Rc<MetalBackend>,
|
backend: &Rc<MetalBackend>,
|
||||||
dev: &Rc<MetalDrmDevice>,
|
dev: &Rc<MetalDrmDevice>,
|
||||||
|
|
@ -1024,7 +1360,7 @@ fn create_connector(
|
||||||
connector: DrmConnector,
|
connector: DrmConnector,
|
||||||
dev: &Rc<MetalDrmDevice>,
|
dev: &Rc<MetalDrmDevice>,
|
||||||
) -> Result<(Rc<MetalConnector>, ConnectorFutures), DrmError> {
|
) -> Result<(Rc<MetalConnector>, ConnectorFutures), DrmError> {
|
||||||
let display = create_connector_display_data(connector, dev)?;
|
let display = create_connector_display_data(connector, dev, None)?;
|
||||||
let slf = Rc::new(MetalConnector {
|
let slf = Rc::new(MetalConnector {
|
||||||
id: connector,
|
id: connector,
|
||||||
master: dev.master.clone(),
|
master: dev.master.clone(),
|
||||||
|
|
@ -1035,6 +1371,8 @@ fn create_connector(
|
||||||
buffers: Default::default(),
|
buffers: Default::default(),
|
||||||
next_buffer: Default::default(),
|
next_buffer: Default::default(),
|
||||||
enabled: Cell::new(true),
|
enabled: Cell::new(true),
|
||||||
|
non_desktop_override: Default::default(),
|
||||||
|
lease: Cell::new(None),
|
||||||
can_present: Cell::new(true),
|
can_present: Cell::new(true),
|
||||||
has_damage: Cell::new(true),
|
has_damage: Cell::new(true),
|
||||||
primary_plane: Default::default(),
|
primary_plane: Default::default(),
|
||||||
|
|
@ -1049,7 +1387,7 @@ fn create_connector(
|
||||||
cursor_enabled: Cell::new(false),
|
cursor_enabled: Cell::new(false),
|
||||||
cursor_buffers: Default::default(),
|
cursor_buffers: Default::default(),
|
||||||
display: RefCell::new(display),
|
display: RefCell::new(display),
|
||||||
connect_sent: Cell::new(false),
|
frontend_state: Cell::new(FrontState::Disconnected),
|
||||||
cursor_changed: Cell::new(false),
|
cursor_changed: Cell::new(false),
|
||||||
cursor_front_buffer: Default::default(),
|
cursor_front_buffer: Default::default(),
|
||||||
cursor_swap_buffer: Cell::new(false),
|
cursor_swap_buffer: Cell::new(false),
|
||||||
|
|
@ -1072,6 +1410,7 @@ fn create_connector(
|
||||||
fn create_connector_display_data(
|
fn create_connector_display_data(
|
||||||
connector: DrmConnector,
|
connector: DrmConnector,
|
||||||
dev: &Rc<MetalDrmDevice>,
|
dev: &Rc<MetalDrmDevice>,
|
||||||
|
non_desktop_override: Option<bool>,
|
||||||
) -> Result<ConnectorDisplayData, DrmError> {
|
) -> Result<ConnectorDisplayData, DrmError> {
|
||||||
let info = dev.master.get_connector_info(connector, true)?;
|
let info = dev.master.get_connector_info(connector, true)?;
|
||||||
let mut crtcs = AHashMap::new();
|
let mut crtcs = AHashMap::new();
|
||||||
|
|
@ -1158,12 +1497,15 @@ fn create_connector_display_data(
|
||||||
}
|
}
|
||||||
let props = collect_properties(&dev.master, connector)?;
|
let props = collect_properties(&dev.master, connector)?;
|
||||||
let connector_type = ConnectorType::from_drm(info.connector_type);
|
let connector_type = ConnectorType::from_drm(info.connector_type);
|
||||||
|
let non_desktop = props.get("non-desktop")?.value.get() != 0;
|
||||||
Ok(ConnectorDisplayData {
|
Ok(ConnectorDisplayData {
|
||||||
crtc_id: props.get("CRTC_ID")?.map(|v| DrmCrtc(v as _)),
|
crtc_id: props.get("CRTC_ID")?.map(|v| DrmCrtc(v as _)),
|
||||||
crtcs,
|
crtcs,
|
||||||
modes: info.modes,
|
modes: info.modes,
|
||||||
mode,
|
mode,
|
||||||
refresh,
|
refresh,
|
||||||
|
non_desktop,
|
||||||
|
non_desktop_effective: non_desktop_override.unwrap_or(non_desktop),
|
||||||
monitor_manufacturer: manufacturer,
|
monitor_manufacturer: manufacturer,
|
||||||
monitor_name: name,
|
monitor_name: name,
|
||||||
monitor_serial_number: serial_number,
|
monitor_serial_number: serial_number,
|
||||||
|
|
@ -1212,6 +1554,7 @@ fn create_crtc(
|
||||||
id: crtc,
|
id: crtc,
|
||||||
idx,
|
idx,
|
||||||
master: master.clone(),
|
master: master.clone(),
|
||||||
|
lease: Cell::new(None),
|
||||||
possible_planes,
|
possible_planes,
|
||||||
connector: Default::default(),
|
connector: Default::default(),
|
||||||
active: props.get("ACTIVE")?.map(|v| v == 1),
|
active: props.get("ACTIVE")?.map(|v| v == 1),
|
||||||
|
|
@ -1296,6 +1639,7 @@ fn create_plane(plane: DrmPlane, master: &Rc<DrmMaster>) -> Result<MetalPlane, D
|
||||||
assigned: Cell::new(false),
|
assigned: Cell::new(false),
|
||||||
mode_w: Cell::new(0),
|
mode_w: Cell::new(0),
|
||||||
mode_h: Cell::new(0),
|
mode_h: Cell::new(0),
|
||||||
|
lease: Cell::new(None),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1449,15 +1793,26 @@ impl MetalBackend {
|
||||||
for c in removed_connectors {
|
for c in removed_connectors {
|
||||||
dev.futures.remove(&c);
|
dev.futures.remove(&c);
|
||||||
if let Some(c) = dev.connectors.remove(&c) {
|
if let Some(c) = dev.connectors.remove(&c) {
|
||||||
if c.connect_sent.get() {
|
if let Some(lease_id) = c.lease.get() {
|
||||||
c.on_change.send_event(ConnectorEvent::Disconnected);
|
if let Some(lease) = dev.dev.leases.remove(&lease_id) {
|
||||||
|
if !lease.try_revoke() {
|
||||||
|
dev.dev.leases_to_break.set(lease_id, lease);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
c.on_change.send_event(ConnectorEvent::Removed);
|
match c.frontend_state.get() {
|
||||||
|
FrontState::Removed | FrontState::Disconnected => {}
|
||||||
|
FrontState::Connected { .. } | FrontState::Unavailable => {
|
||||||
|
c.send_event(ConnectorEvent::Disconnected);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.send_event(ConnectorEvent::Removed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut preserve = Preserve::default();
|
let mut preserve = Preserve::default();
|
||||||
for c in dev.connectors.lock().values() {
|
for c in dev.connectors.lock().values() {
|
||||||
let mut dd = match create_connector_display_data(c.id, &dev.dev) {
|
let dd = create_connector_display_data(c.id, &dev.dev, c.non_desktop_override.get());
|
||||||
|
let mut dd = match dd {
|
||||||
Ok(d) => d,
|
Ok(d) => d,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
log::error!(
|
log::error!(
|
||||||
|
|
@ -1476,15 +1831,38 @@ impl MetalBackend {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mem::swap(old.deref_mut(), &mut dd);
|
mem::swap(old.deref_mut(), &mut dd);
|
||||||
if c.connect_sent.get() {
|
match c.frontend_state.get() {
|
||||||
if !c.enabled.get()
|
FrontState::Removed | FrontState::Disconnected => {}
|
||||||
|| old.connection != ConnectorStatus::Connected
|
FrontState::Connected { .. } | FrontState::Unavailable => {
|
||||||
|| !old.is_same_monitor(&dd)
|
let mut disconnect = false;
|
||||||
{
|
// Disconnect if the connector has been disabled.
|
||||||
c.on_change.send_event(ConnectorEvent::Disconnected);
|
disconnect |= !c.enabled.get();
|
||||||
c.connect_sent.set(false);
|
// If the connector is connected and switched between being a non-desktop
|
||||||
} else if preserve_any {
|
// and desktop device, break leases and disconnect.
|
||||||
preserve.connectors.insert(c.id);
|
disconnect |= old.connection == ConnectorStatus::Connected
|
||||||
|
&& (c.primary_plane.is_none() != old.non_desktop_effective);
|
||||||
|
if c.lease.is_none() {
|
||||||
|
// If the connector is leased, we have to be careful because DRM is
|
||||||
|
// fickle with sending intermittent disconnected states while the
|
||||||
|
// client performs his setup. Otherwise apply the following rules.
|
||||||
|
|
||||||
|
// Disconnect if the connector is no longer connected.
|
||||||
|
disconnect |= old.connection != ConnectorStatus::Connected;
|
||||||
|
// Disconnect if the connected monitor changed.
|
||||||
|
disconnect |= !old.is_same_monitor(&dd);
|
||||||
|
}
|
||||||
|
if disconnect {
|
||||||
|
if let Some(lease_id) = c.lease.get() {
|
||||||
|
if let Some(lease) = dev.dev.leases.remove(&lease_id) {
|
||||||
|
if !lease.try_revoke() {
|
||||||
|
dev.dev.leases_to_break.set(lease_id, lease);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c.send_event(ConnectorEvent::Disconnected);
|
||||||
|
} else if preserve_any {
|
||||||
|
preserve.connectors.insert(c.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1516,6 +1894,12 @@ impl MetalBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send_connected(&self, connector: &Rc<MetalConnector>, dd: &ConnectorDisplayData) {
|
fn send_connected(&self, connector: &Rc<MetalConnector>, dd: &ConnectorDisplayData) {
|
||||||
|
match connector.frontend_state.get() {
|
||||||
|
FrontState::Removed | FrontState::Connected { .. } | FrontState::Unavailable => {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FrontState::Disconnected => {}
|
||||||
|
}
|
||||||
let mut prev_mode = None;
|
let mut prev_mode = None;
|
||||||
let mut modes = vec![];
|
let mut modes = vec![];
|
||||||
for mode in dd.modes.iter().map(|m| m.to_backend()) {
|
for mode in dd.modes.iter().map(|m| m.to_backend()) {
|
||||||
|
|
@ -1523,18 +1907,16 @@ impl MetalBackend {
|
||||||
modes.push(mode);
|
modes.push(mode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
connector
|
connector.send_event(ConnectorEvent::Connected(MonitorInfo {
|
||||||
.on_change
|
modes,
|
||||||
.send_event(ConnectorEvent::Connected(MonitorInfo {
|
manufacturer: dd.monitor_manufacturer.clone(),
|
||||||
modes,
|
product: dd.monitor_name.clone(),
|
||||||
manufacturer: dd.monitor_manufacturer.clone(),
|
serial_number: dd.monitor_serial_number.clone(),
|
||||||
product: dd.monitor_name.clone(),
|
initial_mode: dd.mode.clone().unwrap().to_backend(),
|
||||||
serial_number: dd.monitor_serial_number.clone(),
|
width_mm: dd.mm_width as _,
|
||||||
initial_mode: dd.mode.clone().unwrap().to_backend(),
|
height_mm: dd.mm_height as _,
|
||||||
width_mm: dd.mm_width as _,
|
non_desktop: dd.non_desktop_effective,
|
||||||
height_mm: dd.mm_height as _,
|
}));
|
||||||
}));
|
|
||||||
connector.connect_sent.set(true);
|
|
||||||
connector.send_hardware_cursor();
|
connector.send_hardware_cursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1639,6 +2021,10 @@ impl MetalBackend {
|
||||||
on_change: Default::default(),
|
on_change: Default::default(),
|
||||||
direct_scanout_enabled: Default::default(),
|
direct_scanout_enabled: Default::default(),
|
||||||
is_nvidia,
|
is_nvidia,
|
||||||
|
lease_ids: Default::default(),
|
||||||
|
leases: Default::default(),
|
||||||
|
leases_to_break: Default::default(),
|
||||||
|
paused: Cell::new(false),
|
||||||
});
|
});
|
||||||
|
|
||||||
let (connectors, futures) = get_connectors(self, &dev, &resources.connectors)?;
|
let (connectors, futures) = get_connectors(self, &dev, &resources.connectors)?;
|
||||||
|
|
@ -1718,8 +2104,7 @@ impl MetalBackend {
|
||||||
if let Err(e) = self.update_device_properties(dev) {
|
if let Err(e) = self.update_device_properties(dev) {
|
||||||
return Err(MetalError::UpdateProperties(e));
|
return Err(MetalError::UpdateProperties(e));
|
||||||
}
|
}
|
||||||
let mut preserve = Preserve::default();
|
self.init_drm_device(dev, &mut Preserve::default())?;
|
||||||
self.init_drm_device(dev, &mut preserve)?;
|
|
||||||
for connector in dev.connectors.lock().values() {
|
for connector in dev.connectors.lock().values() {
|
||||||
if connector.primary_plane.is_some() {
|
if connector.primary_plane.is_some() {
|
||||||
connector.schedule_present();
|
connector.schedule_present();
|
||||||
|
|
@ -1777,11 +2162,11 @@ impl MetalBackend {
|
||||||
}
|
}
|
||||||
let dd = connector.display.borrow_mut();
|
let dd = connector.display.borrow_mut();
|
||||||
{
|
{
|
||||||
let global = self.state.outputs.get(&connector.connector_id);
|
let global = self.state.root.outputs.get(&connector.connector_id);
|
||||||
let mut rr = connector.render_result.borrow_mut();
|
let mut rr = connector.render_result.borrow_mut();
|
||||||
if let Some(g) = &global {
|
if let Some(g) = &global {
|
||||||
let refresh = dd.refresh;
|
let refresh = dd.refresh;
|
||||||
let bindings = g.node.global.bindings.borrow_mut();
|
let bindings = g.global.bindings.borrow_mut();
|
||||||
for fb in rr.presentation_feedbacks.drain(..) {
|
for fb in rr.presentation_feedbacks.drain(..) {
|
||||||
if let Some(bindings) = bindings.get(&fb.client.id) {
|
if let Some(bindings) = bindings.get(&fb.client.id) {
|
||||||
for binding in bindings.values() {
|
for binding in bindings.values() {
|
||||||
|
|
@ -1828,6 +2213,8 @@ impl MetalBackend {
|
||||||
if preserve.connectors.contains(&connector.id) {
|
if preserve.connectors.contains(&connector.id) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
connector.buffers.set(None);
|
||||||
|
connector.cursor_buffers.set(None);
|
||||||
connector.primary_plane.set(None);
|
connector.primary_plane.set(None);
|
||||||
connector.cursor_plane.set(None);
|
connector.cursor_plane.set(None);
|
||||||
connector.cursor_enabled.set(false);
|
connector.cursor_enabled.set(false);
|
||||||
|
|
@ -1985,8 +2372,7 @@ impl MetalBackend {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn re_init_drm_device(&self, dev: &Rc<MetalDrmDeviceData>) {
|
fn re_init_drm_device(&self, dev: &Rc<MetalDrmDeviceData>) {
|
||||||
let mut preserve = Preserve::default();
|
if let Err(e) = self.init_drm_device(dev, &mut Preserve::default()) {
|
||||||
if let Err(e) = self.init_drm_device(dev, &mut preserve) {
|
|
||||||
log::error!("Could not initialize device: {}", ErrorFmt(e));
|
log::error!("Could not initialize device: {}", ErrorFmt(e));
|
||||||
}
|
}
|
||||||
for connector in dev.connectors.lock().values() {
|
for connector in dev.connectors.lock().values() {
|
||||||
|
|
@ -1996,11 +2382,19 @@ impl MetalBackend {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn break_leases(&self, dev: &Rc<MetalDrmDeviceData>) {
|
||||||
|
dev.dev
|
||||||
|
.leases_to_break
|
||||||
|
.lock()
|
||||||
|
.retain(|_, lease| !lease.try_revoke());
|
||||||
|
}
|
||||||
|
|
||||||
fn init_drm_device(
|
fn init_drm_device(
|
||||||
&self,
|
&self,
|
||||||
dev: &Rc<MetalDrmDeviceData>,
|
dev: &Rc<MetalDrmDeviceData>,
|
||||||
preserve: &mut Preserve,
|
preserve: &mut Preserve,
|
||||||
) -> Result<(), MetalError> {
|
) -> Result<(), MetalError> {
|
||||||
|
self.break_leases(dev);
|
||||||
let ctx = match self.ctx.get() {
|
let ctx = match self.ctx.get() {
|
||||||
Some(ctx) => ctx,
|
Some(ctx) => ctx,
|
||||||
_ => return Ok(()),
|
_ => return Ok(()),
|
||||||
|
|
@ -2050,9 +2444,9 @@ impl MetalBackend {
|
||||||
|
|
||||||
for connector in dev.connectors.lock().values() {
|
for connector in dev.connectors.lock().values() {
|
||||||
let dd = connector.display.borrow_mut();
|
let dd = connector.display.borrow_mut();
|
||||||
if !connector.enabled.get() || dd.connection != ConnectorStatus::Connected {
|
if should_ignore(connector, &dd) {
|
||||||
if dd.crtc_id.value.get().is_some() {
|
if dd.crtc_id.value.get().is_some() {
|
||||||
log::debug!("Connector is not connected but has an assigned crtc");
|
log::debug!("Connector should be ignored but has an assigned crtc");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -2280,12 +2674,12 @@ impl MetalBackend {
|
||||||
changes: &mut Change,
|
changes: &mut Change,
|
||||||
) -> Result<(), MetalError> {
|
) -> Result<(), MetalError> {
|
||||||
let dd = connector.display.borrow_mut();
|
let dd = connector.display.borrow_mut();
|
||||||
if !connector.enabled.get() || dd.connection != ConnectorStatus::Connected {
|
if should_ignore(connector, &dd) {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let crtc = 'crtc: {
|
let crtc = 'crtc: {
|
||||||
for crtc in dd.crtcs.values() {
|
for crtc in dd.crtcs.values() {
|
||||||
if crtc.connector.is_none() {
|
if crtc.connector.is_none() && crtc.lease.is_none() {
|
||||||
break 'crtc crtc.clone();
|
break 'crtc crtc.clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2333,7 +2727,8 @@ impl MetalBackend {
|
||||||
};
|
};
|
||||||
let (primary_plane, primary_modifiers) = 'primary_plane: {
|
let (primary_plane, primary_modifiers) = 'primary_plane: {
|
||||||
for plane in crtc.possible_planes.values() {
|
for plane in crtc.possible_planes.values() {
|
||||||
if plane.ty == PlaneType::Primary && !plane.assigned.get() {
|
if plane.ty == PlaneType::Primary && !plane.assigned.get() && plane.lease.is_none()
|
||||||
|
{
|
||||||
if let Some(format) = plane.formats.get(&XRGB8888.drm) {
|
if let Some(format) = plane.formats.get(&XRGB8888.drm) {
|
||||||
break 'primary_plane (plane.clone(), &format.modifiers);
|
break 'primary_plane (plane.clone(), &format.modifiers);
|
||||||
}
|
}
|
||||||
|
|
@ -2355,6 +2750,7 @@ impl MetalBackend {
|
||||||
for plane in crtc.possible_planes.values() {
|
for plane in crtc.possible_planes.values() {
|
||||||
if plane.ty == PlaneType::Cursor
|
if plane.ty == PlaneType::Cursor
|
||||||
&& !plane.assigned.get()
|
&& !plane.assigned.get()
|
||||||
|
&& plane.lease.is_none()
|
||||||
&& plane.formats.contains_key(&ARGB8888.drm)
|
&& plane.formats.contains_key(&ARGB8888.drm)
|
||||||
{
|
{
|
||||||
if let Some(format) = plane.formats.get(&ARGB8888.drm) {
|
if let Some(format) = plane.formats.get(&ARGB8888.drm) {
|
||||||
|
|
@ -2428,8 +2824,13 @@ impl MetalBackend {
|
||||||
|
|
||||||
fn start_connector(&self, connector: &Rc<MetalConnector>, log_mode: bool) {
|
fn start_connector(&self, connector: &Rc<MetalConnector>, log_mode: bool) {
|
||||||
let dd = connector.display.borrow_mut();
|
let dd = connector.display.borrow_mut();
|
||||||
if !connector.connect_sent.get() {
|
self.send_connected(connector, &dd);
|
||||||
self.send_connected(connector, &dd);
|
match connector.frontend_state.get() {
|
||||||
|
FrontState::Connected { non_desktop: false } => {}
|
||||||
|
FrontState::Connected { non_desktop: true }
|
||||||
|
| FrontState::Removed
|
||||||
|
| FrontState::Disconnected
|
||||||
|
| FrontState::Unavailable => return,
|
||||||
}
|
}
|
||||||
if log_mode {
|
if log_mode {
|
||||||
log::info!(
|
log::info!(
|
||||||
|
|
@ -2495,3 +2896,9 @@ fn modes_equal(a: &DrmModeInfo, b: &DrmModeInfo) -> bool {
|
||||||
&& a.vrefresh == b.vrefresh
|
&& a.vrefresh == b.vrefresh
|
||||||
&& a.flags == b.flags
|
&& a.flags == b.flags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn should_ignore(connector: &MetalConnector, dd: &ConnectorDisplayData) -> bool {
|
||||||
|
!connector.enabled.get()
|
||||||
|
|| dd.connection != ConnectorStatus::Connected
|
||||||
|
|| dd.non_desktop_effective
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -574,6 +574,7 @@ impl XBackend {
|
||||||
},
|
},
|
||||||
width_mm: output.width.get(),
|
width_mm: output.width.get(),
|
||||||
height_mm: output.height.get(),
|
height_mm: output.height.get(),
|
||||||
|
non_desktop: false,
|
||||||
}));
|
}));
|
||||||
output.changed();
|
output.changed();
|
||||||
self.present(output).await;
|
self.present(output).await;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use {
|
||||||
utils::transform_ext::TransformExt,
|
utils::transform_ext::TransformExt,
|
||||||
wire::{jay_compositor, jay_randr, JayRandrId},
|
wire::{jay_compositor, jay_randr, JayRandrId},
|
||||||
},
|
},
|
||||||
clap::{Args, Subcommand},
|
clap::{Args, Subcommand, ValueEnum},
|
||||||
isnt::std_1::vec::IsntVecExt,
|
isnt::std_1::vec::IsntVecExt,
|
||||||
jay_config::video::Transform,
|
jay_config::video::Transform,
|
||||||
std::{
|
std::{
|
||||||
|
|
@ -115,6 +115,21 @@ pub enum OutputCommand {
|
||||||
Enable,
|
Enable,
|
||||||
/// Disable the output.
|
/// Disable the output.
|
||||||
Disable,
|
Disable,
|
||||||
|
/// Override the display's non-desktop setting.
|
||||||
|
NonDesktop(NonDesktopArgs),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(ValueEnum, Debug, Clone)]
|
||||||
|
pub enum NonDesktopType {
|
||||||
|
Default,
|
||||||
|
False,
|
||||||
|
True,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Args, Debug, Clone)]
|
||||||
|
pub struct NonDesktopArgs {
|
||||||
|
/// Whether this output is a non-desktop output.
|
||||||
|
pub setting: NonDesktopType,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Args, Debug, Clone)]
|
#[derive(Args, Debug, Clone)]
|
||||||
|
|
@ -217,6 +232,7 @@ struct Output {
|
||||||
pub height_mm: i32,
|
pub height_mm: i32,
|
||||||
pub current_mode: Option<Mode>,
|
pub current_mode: Option<Mode>,
|
||||||
pub modes: Vec<Mode>,
|
pub modes: Vec<Mode>,
|
||||||
|
pub non_desktop: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug)]
|
#[derive(Copy, Clone, Debug)]
|
||||||
|
|
@ -373,6 +389,16 @@ impl Randr {
|
||||||
enabled: enable as _,
|
enabled: enable as _,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
OutputCommand::NonDesktop(a) => {
|
||||||
|
self.handle_error(randr, move |msg| {
|
||||||
|
eprintln!("Could not change the non-desktop setting: {}", msg);
|
||||||
|
});
|
||||||
|
tc.send(jay_randr::SetNonDesktop {
|
||||||
|
self_id: randr,
|
||||||
|
output: &args.output,
|
||||||
|
non_desktop: a.setting as _,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
tc.round_trip().await;
|
tc.round_trip().await;
|
||||||
}
|
}
|
||||||
|
|
@ -479,12 +505,16 @@ impl Randr {
|
||||||
println!(" product: {}", o.product);
|
println!(" product: {}", o.product);
|
||||||
println!(" manufacturer: {}", o.manufacturer);
|
println!(" manufacturer: {}", o.manufacturer);
|
||||||
println!(" serial number: {}", o.serial_number);
|
println!(" serial number: {}", o.serial_number);
|
||||||
println!(" position: {} x {}", o.x, o.y);
|
|
||||||
println!(" logical size: {} x {}", o.width, o.height);
|
|
||||||
println!(
|
println!(
|
||||||
" physical size: {}mm x {}mm",
|
" physical size: {}mm x {}mm",
|
||||||
o.width_mm, o.height_mm
|
o.width_mm, o.height_mm
|
||||||
);
|
);
|
||||||
|
if o.non_desktop {
|
||||||
|
println!(" non-desktop");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
println!(" position: {} x {}", o.x, o.y);
|
||||||
|
println!(" logical size: {} x {}", o.width, o.height);
|
||||||
if let Some(mode) = &o.current_mode {
|
if let Some(mode) = &o.current_mode {
|
||||||
print!(" mode: ");
|
print!(" mode: ");
|
||||||
self.print_mode(mode, false);
|
self.print_mode(mode, false);
|
||||||
|
|
@ -570,6 +600,27 @@ impl Randr {
|
||||||
height_mm: msg.height_mm,
|
height_mm: msg.height_mm,
|
||||||
modes: Default::default(),
|
modes: Default::default(),
|
||||||
current_mode: None,
|
current_mode: None,
|
||||||
|
non_desktop: false,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
jay_randr::NonDesktopOutput::handle(tc, randr, data.clone(), |data, msg| {
|
||||||
|
let mut data = data.borrow_mut();
|
||||||
|
let c = data.connectors.last_mut().unwrap();
|
||||||
|
c.output = Some(Output {
|
||||||
|
scale: 1.0,
|
||||||
|
width: 0,
|
||||||
|
height: 0,
|
||||||
|
x: 0,
|
||||||
|
y: 0,
|
||||||
|
transform: Transform::None,
|
||||||
|
manufacturer: msg.manufacturer.to_string(),
|
||||||
|
product: msg.product.to_string(),
|
||||||
|
serial_number: msg.serial_number.to_string(),
|
||||||
|
width_mm: msg.width_mm,
|
||||||
|
height_mm: msg.height_mm,
|
||||||
|
modes: Default::default(),
|
||||||
|
current_mode: None,
|
||||||
|
non_desktop: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
jay_randr::Mode::handle(tc, randr, data.clone(), |data, msg| {
|
jay_randr::Mode::handle(tc, randr, data.clone(), |data, msg| {
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,12 @@ bitflags! {
|
||||||
CAP_LAYER_SHELL = 1 << 6,
|
CAP_LAYER_SHELL = 1 << 6,
|
||||||
CAP_SCREENCOPY_MANAGER = 1 << 7,
|
CAP_SCREENCOPY_MANAGER = 1 << 7,
|
||||||
CAP_SEAT_MANAGER = 1 << 8,
|
CAP_SEAT_MANAGER = 1 << 8,
|
||||||
|
CAP_DRM_LEASE = 1 << 9,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub const CAPS_DEFAULT: ClientCaps = ClientCaps(CAP_LAYER_SHELL.0 | CAP_DRM_LEASE.0);
|
||||||
|
pub const CAPS_DEFAULT_SANDBOXED: ClientCaps = ClientCaps(CAP_DRM_LEASE.0);
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
|
#[derive(Debug, Copy, Clone, Hash, Ord, PartialOrd, Eq, PartialEq)]
|
||||||
pub struct ClientId(u64);
|
pub struct ClientId(u64);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ use {
|
||||||
xdg_surface::{xdg_toplevel::XdgToplevel, XdgSurface},
|
xdg_surface::{xdg_toplevel::XdgToplevel, XdgSurface},
|
||||||
WlSurface,
|
WlSurface,
|
||||||
},
|
},
|
||||||
|
wp_drm_lease_connector_v1::WpDrmLeaseConnectorV1,
|
||||||
wp_linux_drm_syncobj_timeline_v1::WpLinuxDrmSyncobjTimelineV1,
|
wp_linux_drm_syncobj_timeline_v1::WpLinuxDrmSyncobjTimelineV1,
|
||||||
xdg_positioner::XdgPositioner,
|
xdg_positioner::XdgPositioner,
|
||||||
xdg_wm_base::XdgWmBase,
|
xdg_wm_base::XdgWmBase,
|
||||||
|
|
@ -32,8 +33,9 @@ use {
|
||||||
wire::{
|
wire::{
|
||||||
JayOutputId, JayScreencastId, JayToplevelId, JayWorkspaceId, WlBufferId,
|
JayOutputId, JayScreencastId, JayToplevelId, JayWorkspaceId, WlBufferId,
|
||||||
WlDataSourceId, WlOutputId, WlPointerId, WlRegionId, WlRegistryId, WlSeatId,
|
WlDataSourceId, WlOutputId, WlPointerId, WlRegionId, WlRegistryId, WlSeatId,
|
||||||
WlSurfaceId, WpLinuxDrmSyncobjTimelineV1Id, XdgPositionerId, XdgSurfaceId,
|
WlSurfaceId, WpDrmLeaseConnectorV1Id, WpLinuxDrmSyncobjTimelineV1Id, XdgPositionerId,
|
||||||
XdgToplevelId, XdgWmBaseId, ZwlrDataControlSourceV1Id, ZwpPrimarySelectionSourceV1Id,
|
XdgSurfaceId, XdgToplevelId, XdgWmBaseId, ZwlrDataControlSourceV1Id,
|
||||||
|
ZwpPrimarySelectionSourceV1Id,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
std::{cell::RefCell, mem, rc::Rc},
|
std::{cell::RefCell, mem, rc::Rc},
|
||||||
|
|
@ -62,6 +64,7 @@ pub struct Objects {
|
||||||
pub timelines: CopyHashMap<WpLinuxDrmSyncobjTimelineV1Id, Rc<WpLinuxDrmSyncobjTimelineV1>>,
|
pub timelines: CopyHashMap<WpLinuxDrmSyncobjTimelineV1Id, Rc<WpLinuxDrmSyncobjTimelineV1>>,
|
||||||
pub zwlr_data_sources: CopyHashMap<ZwlrDataControlSourceV1Id, Rc<ZwlrDataControlSourceV1>>,
|
pub zwlr_data_sources: CopyHashMap<ZwlrDataControlSourceV1Id, Rc<ZwlrDataControlSourceV1>>,
|
||||||
pub jay_toplevels: CopyHashMap<JayToplevelId, Rc<JayToplevel>>,
|
pub jay_toplevels: CopyHashMap<JayToplevelId, Rc<JayToplevel>>,
|
||||||
|
pub drm_lease_outputs: CopyHashMap<WpDrmLeaseConnectorV1Id, Rc<WpDrmLeaseConnectorV1>>,
|
||||||
ids: RefCell<Vec<usize>>,
|
ids: RefCell<Vec<usize>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,6 +95,7 @@ impl Objects {
|
||||||
timelines: Default::default(),
|
timelines: Default::default(),
|
||||||
zwlr_data_sources: Default::default(),
|
zwlr_data_sources: Default::default(),
|
||||||
jay_toplevels: Default::default(),
|
jay_toplevels: Default::default(),
|
||||||
|
drm_lease_outputs: Default::default(),
|
||||||
ids: RefCell::new(vec![]),
|
ids: RefCell::new(vec![]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -126,6 +130,7 @@ impl Objects {
|
||||||
self.timelines.clear();
|
self.timelines.clear();
|
||||||
self.zwlr_data_sources.clear();
|
self.zwlr_data_sources.clear();
|
||||||
self.jay_toplevels.clear();
|
self.jay_toplevels.clear();
|
||||||
|
self.drm_lease_outputs.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn id<T>(&self, client_data: &Client) -> Result<T, ClientError>
|
pub fn id<T>(&self, client_data: &Client) -> Result<T, ClientError>
|
||||||
|
|
|
||||||
|
|
@ -514,6 +514,14 @@ impl ConfigProxyHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_output_node(&self, connector: Connector) -> Result<Rc<OutputNode>, CphError> {
|
||||||
|
let data = self.get_output(connector)?;
|
||||||
|
match data.node.clone() {
|
||||||
|
Some(d) => Ok(d),
|
||||||
|
_ => Err(CphError::OutputIsNotDesktop(connector)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn get_drm_device(&self, dev: DrmDevice) -> Result<Rc<DrmDevData>, CphError> {
|
fn get_drm_device(&self, dev: DrmDevice) -> Result<Rc<DrmDevData>, CphError> {
|
||||||
match self.state.drm_devs.get(&DrmDeviceId::from_raw(dev.0 as _)) {
|
match self.state.drm_devs.get(&DrmDeviceId::from_raw(dev.0 as _)) {
|
||||||
Some(dev) => Ok(dev),
|
Some(dev) => Ok(dev),
|
||||||
|
|
@ -783,7 +791,7 @@ impl ConfigProxyHandler {
|
||||||
workspace: WorkspaceSource,
|
workspace: WorkspaceSource,
|
||||||
connector: Connector,
|
connector: Connector,
|
||||||
) -> Result<(), CphError> {
|
) -> Result<(), CphError> {
|
||||||
let output = self.get_output(connector)?;
|
let output = self.get_output_node(connector)?;
|
||||||
let ws = match workspace {
|
let ws = match workspace {
|
||||||
WorkspaceSource::Explicit(ws) => {
|
WorkspaceSource::Explicit(ws) => {
|
||||||
let name = self.get_workspace(ws)?;
|
let name = self.get_workspace(ws)?;
|
||||||
|
|
@ -797,10 +805,10 @@ impl ConfigProxyHandler {
|
||||||
_ => return Ok(()),
|
_ => return Ok(()),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
if ws.is_dummy || output.node.is_dummy {
|
if ws.is_dummy || output.is_dummy {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
if ws.output.get().id == output.node.id {
|
if ws.output.get().id == output.id {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let link = match &*ws.output_link.borrow() {
|
let link = match &*ws.output_link.borrow() {
|
||||||
|
|
@ -811,8 +819,8 @@ impl ConfigProxyHandler {
|
||||||
make_visible_if_empty: true,
|
make_visible_if_empty: true,
|
||||||
source_is_destroyed: false,
|
source_is_destroyed: false,
|
||||||
};
|
};
|
||||||
move_ws_to_output(&link, &output.node, config);
|
move_ws_to_output(&link, &output, config);
|
||||||
ws.desired_output.set(output.node.global.output_id.clone());
|
ws.desired_output.set(output.global.output_id.clone());
|
||||||
self.state.tree_changed();
|
self.state.tree_changed();
|
||||||
self.state.damage();
|
self.state.damage();
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -856,8 +864,8 @@ impl ConfigProxyHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_connector_mode(&self, connector: Connector) -> Result<(), CphError> {
|
fn handle_connector_mode(&self, connector: Connector) -> Result<(), CphError> {
|
||||||
let connector = self.get_output(connector)?;
|
let connector = self.get_output_node(connector)?;
|
||||||
let mode = connector.node.global.mode.get();
|
let mode = connector.global.mode.get();
|
||||||
self.respond(Response::ConnectorMode {
|
self.respond(Response::ConnectorMode {
|
||||||
width: mode.width,
|
width: mode.width,
|
||||||
height: mode.height,
|
height: mode.height,
|
||||||
|
|
@ -881,10 +889,9 @@ impl ConfigProxyHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_connector_modes(&self, connector: Connector) -> Result<(), CphError> {
|
fn handle_connector_modes(&self, connector: Connector) -> Result<(), CphError> {
|
||||||
let connector = self.get_output(connector)?;
|
let connector = self.get_output_node(connector)?;
|
||||||
self.respond(Response::ConnectorModes {
|
self.respond(Response::ConnectorModes {
|
||||||
modes: connector
|
modes: connector
|
||||||
.node
|
|
||||||
.global
|
.global
|
||||||
.modes
|
.modes
|
||||||
.iter()
|
.iter()
|
||||||
|
|
@ -964,8 +971,8 @@ impl ConfigProxyHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_connector_size(&self, connector: Connector) -> Result<(), CphError> {
|
fn handle_connector_size(&self, connector: Connector) -> Result<(), CphError> {
|
||||||
let connector = self.get_output(connector)?;
|
let connector = self.get_output_node(connector)?;
|
||||||
let pos = connector.node.global.pos.get();
|
let pos = connector.global.pos.get();
|
||||||
self.respond(Response::ConnectorSize {
|
self.respond(Response::ConnectorSize {
|
||||||
width: pos.width(),
|
width: pos.width(),
|
||||||
height: pos.height(),
|
height: pos.height(),
|
||||||
|
|
@ -974,9 +981,9 @@ impl ConfigProxyHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_connector_get_scale(&self, connector: Connector) -> Result<(), CphError> {
|
fn handle_connector_get_scale(&self, connector: Connector) -> Result<(), CphError> {
|
||||||
let connector = self.get_output(connector)?;
|
let connector = self.get_output_node(connector)?;
|
||||||
self.respond(Response::ConnectorGetScale {
|
self.respond(Response::ConnectorGetScale {
|
||||||
scale: connector.node.global.persistent.scale.get().to_f64(),
|
scale: connector.global.persistent.scale.get().to_f64(),
|
||||||
});
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -989,8 +996,8 @@ impl ConfigProxyHandler {
|
||||||
return Err(CphError::ScaleTooLarge(scale));
|
return Err(CphError::ScaleTooLarge(scale));
|
||||||
}
|
}
|
||||||
let scale = Scale::from_f64(scale);
|
let scale = Scale::from_f64(scale);
|
||||||
let connector = self.get_output(connector)?;
|
let connector = self.get_output_node(connector)?;
|
||||||
connector.node.set_preferred_scale(scale);
|
connector.set_preferred_scale(scale);
|
||||||
self.state.damage();
|
self.state.damage();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -1000,8 +1007,8 @@ impl ConfigProxyHandler {
|
||||||
connector: Connector,
|
connector: Connector,
|
||||||
transform: Transform,
|
transform: Transform,
|
||||||
) -> Result<(), CphError> {
|
) -> Result<(), CphError> {
|
||||||
let connector = self.get_output(connector)?;
|
let connector = self.get_output_node(connector)?;
|
||||||
connector.node.update_transform(transform);
|
connector.update_transform(transform);
|
||||||
self.state.damage();
|
self.state.damage();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -1012,15 +1019,15 @@ impl ConfigProxyHandler {
|
||||||
x: i32,
|
x: i32,
|
||||||
y: i32,
|
y: i32,
|
||||||
) -> Result<(), CphError> {
|
) -> Result<(), CphError> {
|
||||||
let connector = self.get_output(connector)?;
|
let connector = self.get_output_node(connector)?;
|
||||||
if x < 0 || y < 0 || x > MAX_EXTENTS || y > MAX_EXTENTS {
|
if x < 0 || y < 0 || x > MAX_EXTENTS || y > MAX_EXTENTS {
|
||||||
return Err(CphError::InvalidConnectorPosition(x, y));
|
return Err(CphError::InvalidConnectorPosition(x, y));
|
||||||
}
|
}
|
||||||
let old_pos = connector.node.global.pos.get();
|
let old_pos = connector.global.pos.get();
|
||||||
connector.node.set_position(x, y);
|
connector.set_position(x, y);
|
||||||
let seats = self.state.globals.seats.lock();
|
let seats = self.state.globals.seats.lock();
|
||||||
for seat in seats.values() {
|
for seat in seats.values() {
|
||||||
if seat.get_output().id == connector.node.id {
|
if seat.get_output().id == connector.id {
|
||||||
let seat_pos = seat.position();
|
let seat_pos = seat.position();
|
||||||
seat.set_position(
|
seat.set_position(
|
||||||
seat_pos.0.round_down() + x - old_pos.x1(),
|
seat_pos.0.round_down() + x - old_pos.x1(),
|
||||||
|
|
@ -1032,8 +1039,8 @@ impl ConfigProxyHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_connector_get_position(&self, connector: Connector) -> Result<(), CphError> {
|
fn handle_connector_get_position(&self, connector: Connector) -> Result<(), CphError> {
|
||||||
let connector = self.get_output(connector)?;
|
let connector = self.get_output_node(connector)?;
|
||||||
let (x, y) = connector.node.global.pos.get().position();
|
let (x, y) = connector.global.pos.get().position();
|
||||||
self.respond(Response::ConnectorGetPosition { x, y });
|
self.respond(Response::ConnectorGetPosition { x, y });
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -1813,6 +1820,8 @@ enum CphError {
|
||||||
TimerDoesNotExist(JayTimer),
|
TimerDoesNotExist(JayTimer),
|
||||||
#[error("Connector {0:?} does not exist or is not connected")]
|
#[error("Connector {0:?} does not exist or is not connected")]
|
||||||
OutputDoesNotExist(Connector),
|
OutputDoesNotExist(Connector),
|
||||||
|
#[error("Output {0:?} is not a desktop output")]
|
||||||
|
OutputIsNotDesktop(Connector),
|
||||||
#[error("{0}x{1} is not a valid connector position")]
|
#[error("{0}x{1} is not a valid connector position")]
|
||||||
InvalidConnectorPosition(i32, i32),
|
InvalidConnectorPosition(i32, i32),
|
||||||
#[error("Keymap {0:?} does not exist")]
|
#[error("Keymap {0:?} does not exist")]
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,10 @@ pub mod wp_content_type_manager_v1;
|
||||||
pub mod wp_content_type_v1;
|
pub mod wp_content_type_v1;
|
||||||
pub mod wp_cursor_shape_device_v1;
|
pub mod wp_cursor_shape_device_v1;
|
||||||
pub mod wp_cursor_shape_manager_v1;
|
pub mod wp_cursor_shape_manager_v1;
|
||||||
|
pub mod wp_drm_lease_connector_v1;
|
||||||
|
pub mod wp_drm_lease_device_v1;
|
||||||
|
pub mod wp_drm_lease_request_v1;
|
||||||
|
pub mod wp_drm_lease_v1;
|
||||||
pub mod wp_fractional_scale_manager_v1;
|
pub mod wp_fractional_scale_manager_v1;
|
||||||
pub mod wp_linux_drm_syncobj_manager_v1;
|
pub mod wp_linux_drm_syncobj_manager_v1;
|
||||||
pub mod wp_linux_drm_syncobj_timeline_v1;
|
pub mod wp_linux_drm_syncobj_timeline_v1;
|
||||||
|
|
|
||||||
|
|
@ -90,8 +90,8 @@ impl ExtSessionLockV1RequestHandler for ExtSessionLockV1 {
|
||||||
let state = &self.client.state;
|
let state = &self.client.state;
|
||||||
state.lock.locked.set(false);
|
state.lock.locked.set(false);
|
||||||
state.lock.lock.take();
|
state.lock.lock.take();
|
||||||
for output in state.outputs.lock().values() {
|
for output in state.root.outputs.lock().values() {
|
||||||
if let Some(surface) = output.node.set_lock_surface(None) {
|
if let Some(surface) = output.set_lock_surface(None) {
|
||||||
surface.destroy_node();
|
surface.destroy_node();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -220,8 +220,8 @@ impl JayCompositorRequestHandler for JayCompositor {
|
||||||
if let Some(lock) = state.lock.lock.take() {
|
if let Some(lock) = state.lock.lock.take() {
|
||||||
lock.finish();
|
lock.finish();
|
||||||
}
|
}
|
||||||
for output in state.outputs.lock().values() {
|
for output in state.root.outputs.lock().values() {
|
||||||
if let Some(surface) = output.node.set_lock_surface(None) {
|
if let Some(surface) = output.set_lock_surface(None) {
|
||||||
surface.destroy_node();
|
surface.destroy_node();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ use {
|
||||||
object::{Object, Version},
|
object::{Object, Version},
|
||||||
scale::Scale,
|
scale::Scale,
|
||||||
state::{ConnectorData, DrmDevData, OutputData},
|
state::{ConnectorData, DrmDevData, OutputData},
|
||||||
|
tree::OutputNode,
|
||||||
utils::{gfx_api_ext::GfxApiExt, transform_ext::TransformExt},
|
utils::{gfx_api_ext::GfxApiExt, transform_ext::TransformExt},
|
||||||
wire::{jay_randr::*, JayRandrId},
|
wire::{jay_randr::*, JayRandrId},
|
||||||
},
|
},
|
||||||
|
|
@ -64,33 +65,47 @@ impl JayRandr {
|
||||||
enabled: data.connector.enabled() as _,
|
enabled: data.connector.enabled() as _,
|
||||||
name: &data.name,
|
name: &data.name,
|
||||||
});
|
});
|
||||||
if let Some(output) = self.client.state.outputs.get(&data.connector.id()) {
|
let Some(output) = self.client.state.outputs.get(&data.connector.id()) else {
|
||||||
let global = &output.node.global;
|
return;
|
||||||
let pos = global.pos.get();
|
};
|
||||||
self.client.event(Output {
|
let global = match output.node.as_ref().map(|n| &n.global) {
|
||||||
self_id: self.id,
|
Some(g) => g,
|
||||||
scale: global.persistent.scale.get().to_wl(),
|
_ => {
|
||||||
width: pos.width(),
|
self.client.event(NonDesktopOutput {
|
||||||
height: pos.height(),
|
|
||||||
x: pos.x1(),
|
|
||||||
y: pos.y1(),
|
|
||||||
transform: global.persistent.transform.get().to_wl(),
|
|
||||||
manufacturer: &output.monitor_info.manufacturer,
|
|
||||||
product: &output.monitor_info.product,
|
|
||||||
serial_number: &output.monitor_info.serial_number,
|
|
||||||
width_mm: global.width_mm,
|
|
||||||
height_mm: global.height_mm,
|
|
||||||
});
|
|
||||||
let current_mode = global.mode.get();
|
|
||||||
for mode in &global.modes {
|
|
||||||
self.client.event(Mode {
|
|
||||||
self_id: self.id,
|
self_id: self.id,
|
||||||
width: mode.width,
|
manufacturer: &output.monitor_info.manufacturer,
|
||||||
height: mode.height,
|
product: &output.monitor_info.product,
|
||||||
refresh_rate_millihz: mode.refresh_rate_millihz,
|
serial_number: &output.monitor_info.serial_number,
|
||||||
current: (mode == ¤t_mode) as _,
|
width_mm: output.monitor_info.width_mm,
|
||||||
|
height_mm: output.monitor_info.height_mm,
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
let pos = global.pos.get();
|
||||||
|
self.client.event(Output {
|
||||||
|
self_id: self.id,
|
||||||
|
scale: global.persistent.scale.get().to_wl(),
|
||||||
|
width: pos.width(),
|
||||||
|
height: pos.height(),
|
||||||
|
x: pos.x1(),
|
||||||
|
y: pos.y1(),
|
||||||
|
transform: global.persistent.transform.get().to_wl(),
|
||||||
|
manufacturer: &output.monitor_info.manufacturer,
|
||||||
|
product: &output.monitor_info.product,
|
||||||
|
serial_number: &output.monitor_info.serial_number,
|
||||||
|
width_mm: global.width_mm,
|
||||||
|
height_mm: global.height_mm,
|
||||||
|
});
|
||||||
|
let current_mode = global.mode.get();
|
||||||
|
for mode in &global.modes {
|
||||||
|
self.client.event(Mode {
|
||||||
|
self_id: self.id,
|
||||||
|
width: mode.width,
|
||||||
|
height: mode.height,
|
||||||
|
refresh_rate_millihz: mode.refresh_rate_millihz,
|
||||||
|
current: (mode == ¤t_mode) as _,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -144,6 +159,18 @@ impl JayRandr {
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_output_node(&self, name: &str) -> Option<Rc<OutputNode>> {
|
||||||
|
let output = self.get_output(name)?;
|
||||||
|
match output.node.clone() {
|
||||||
|
Some(n) => return Some(n),
|
||||||
|
_ => self.send_error(&format!(
|
||||||
|
"Display connected to {} is not a desktop display",
|
||||||
|
output.connector.name
|
||||||
|
)),
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl JayRandrRequestHandler for JayRandr {
|
impl JayRandrRequestHandler for JayRandr {
|
||||||
|
|
@ -203,22 +230,22 @@ impl JayRandrRequestHandler for JayRandr {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_transform(&self, req: SetTransform, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
fn set_transform(&self, req: SetTransform, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||||
let Some(c) = self.get_output(req.output) else {
|
let Some(c) = self.get_output_node(req.output) else {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
let Some(transform) = Transform::from_wl(req.transform) else {
|
let Some(transform) = Transform::from_wl(req.transform) else {
|
||||||
self.send_error(&format!("Unknown transform {}", req.transform));
|
self.send_error(&format!("Unknown transform {}", req.transform));
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
c.node.update_transform(transform);
|
c.update_transform(transform);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_scale(&self, req: SetScale, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
fn set_scale(&self, req: SetScale, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||||
let Some(c) = self.get_output(req.output) else {
|
let Some(c) = self.get_output_node(req.output) else {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
c.node.set_preferred_scale(Scale::from_wl(req.scale));
|
c.set_preferred_scale(Scale::from_wl(req.scale));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -235,7 +262,7 @@ impl JayRandrRequestHandler for JayRandr {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_position(&self, req: SetPosition, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
fn set_position(&self, req: SetPosition, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||||
let Some(c) = self.get_output(req.output) else {
|
let Some(c) = self.get_output_node(req.output) else {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
if req.x < 0 || req.y < 0 {
|
if req.x < 0 || req.y < 0 {
|
||||||
|
|
@ -246,7 +273,7 @@ impl JayRandrRequestHandler for JayRandr {
|
||||||
self.send_error(&format!("x and y cannot be greater than {MAX_EXTENTS}"));
|
self.send_error(&format!("x and y cannot be greater than {MAX_EXTENTS}"));
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
c.node.set_position(req.x, req.y);
|
c.set_position(req.x, req.y);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -257,6 +284,19 @@ impl JayRandrRequestHandler for JayRandr {
|
||||||
c.connector.set_enabled(req.enabled != 0);
|
c.connector.set_enabled(req.enabled != 0);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_non_desktop(&self, req: SetNonDesktop<'_>, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||||
|
let Some(c) = self.get_connector(req.output) else {
|
||||||
|
return Ok(());
|
||||||
|
};
|
||||||
|
let non_desktop = match req.non_desktop {
|
||||||
|
0 => None,
|
||||||
|
1 => Some(false),
|
||||||
|
_ => Some(true),
|
||||||
|
};
|
||||||
|
c.connector.set_non_desktop_override(non_desktop);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
object_base! {
|
object_base! {
|
||||||
|
|
|
||||||
|
|
@ -596,10 +596,10 @@ impl WlSeatGlobal {
|
||||||
self.update_hardware_cursor_position();
|
self.update_hardware_cursor_position();
|
||||||
self.trigger_tree_changed();
|
self.trigger_tree_changed();
|
||||||
let output = 'set_output: {
|
let output = 'set_output: {
|
||||||
let outputs = self.state.outputs.lock();
|
let outputs = self.state.root.outputs.lock();
|
||||||
for output in outputs.values() {
|
for output in outputs.values() {
|
||||||
if output.node.global.pos.get().contains(x, y) {
|
if output.global.pos.get().contains(x, y) {
|
||||||
break 'set_output output.node.clone();
|
break 'set_output output.clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.state.dummy_output.get().unwrap()
|
self.state.dummy_output.get().unwrap()
|
||||||
|
|
|
||||||
|
|
@ -241,12 +241,12 @@ impl WlSeatGlobal {
|
||||||
mut x: Fixed,
|
mut x: Fixed,
|
||||||
mut y: Fixed,
|
mut y: Fixed,
|
||||||
) {
|
) {
|
||||||
let output = match self.state.outputs.get(&connector) {
|
let output = match self.state.root.outputs.get(&connector) {
|
||||||
Some(o) => o,
|
Some(o) => o,
|
||||||
_ => return,
|
_ => return,
|
||||||
};
|
};
|
||||||
self.set_output(&output.node);
|
self.set_output(&output);
|
||||||
let pos = output.node.global.pos.get();
|
let pos = output.global.pos.get();
|
||||||
x += Fixed::from_int(pos.x1());
|
x += Fixed::from_int(pos.x1());
|
||||||
y += Fixed::from_int(pos.y1());
|
y += Fixed::from_int(pos.y1());
|
||||||
if let Some(c) = self.constraint.get() {
|
if let Some(c) = self.constraint.get() {
|
||||||
|
|
@ -314,10 +314,10 @@ impl WlSeatGlobal {
|
||||||
let mut y_int = y.round_down();
|
let mut y_int = y.round_down();
|
||||||
if !pos.contains(x_int, y_int) {
|
if !pos.contains(x_int, y_int) {
|
||||||
'warp: {
|
'warp: {
|
||||||
let outputs = self.state.outputs.lock();
|
let outputs = self.state.root.outputs.lock();
|
||||||
for output in outputs.values() {
|
for output in outputs.values() {
|
||||||
if output.node.global.pos.get().contains(x_int, y_int) {
|
if output.global.pos.get().contains(x_int, y_int) {
|
||||||
self.set_output(&output.node);
|
self.set_output(output);
|
||||||
break 'warp;
|
break 'warp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
93
src/ifs/wp_drm_lease_connector_v1.rs
Normal file
93
src/ifs/wp_drm_lease_connector_v1.rs
Normal file
|
|
@ -0,0 +1,93 @@
|
||||||
|
use {
|
||||||
|
crate::{
|
||||||
|
backend::ConnectorId as BackendConnectorId,
|
||||||
|
client::{Client, ClientError},
|
||||||
|
ifs::wp_drm_lease_device_v1::WpDrmLeaseDeviceV1,
|
||||||
|
leaks::Tracker,
|
||||||
|
object::{Object, Version},
|
||||||
|
utils::bindings::Bindings,
|
||||||
|
wire::{wp_drm_lease_connector_v1::*, WpDrmLeaseConnectorV1Id},
|
||||||
|
},
|
||||||
|
std::rc::Rc,
|
||||||
|
thiserror::Error,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub struct WpDrmLeaseConnectorV1 {
|
||||||
|
pub id: WpDrmLeaseConnectorV1Id,
|
||||||
|
pub client: Rc<Client>,
|
||||||
|
pub tracker: Tracker<Self>,
|
||||||
|
pub version: Version,
|
||||||
|
pub device: Rc<WpDrmLeaseDeviceV1>,
|
||||||
|
pub connector_id: BackendConnectorId,
|
||||||
|
pub bindings: Rc<Bindings<Self>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WpDrmLeaseConnectorV1 {
|
||||||
|
fn detach(&self) {
|
||||||
|
self.bindings.remove(&self.client, self);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn send_name(&self, name: &str) {
|
||||||
|
self.client.event(Name {
|
||||||
|
self_id: self.id,
|
||||||
|
name,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn send_description(&self, description: &str) {
|
||||||
|
self.client.event(Description {
|
||||||
|
self_id: self.id,
|
||||||
|
description,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn send_connector_id(&self, connector_id: u32) {
|
||||||
|
self.client.event(ConnectorId {
|
||||||
|
self_id: self.id,
|
||||||
|
connector_id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn send_done(&self) {
|
||||||
|
self.client.event(Done { self_id: self.id });
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn send_withdrawn(&self) {
|
||||||
|
self.client.event(Withdrawn { self_id: self.id });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WpDrmLeaseConnectorV1RequestHandler for WpDrmLeaseConnectorV1 {
|
||||||
|
type Error = WpDrmLeaseConnectorV1Error;
|
||||||
|
|
||||||
|
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||||
|
self.detach();
|
||||||
|
self.client.remove_obj(self)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object_base! {
|
||||||
|
self = WpDrmLeaseConnectorV1;
|
||||||
|
version = self.version;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Object for WpDrmLeaseConnectorV1 {
|
||||||
|
fn break_loops(&self) {
|
||||||
|
self.detach();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dedicated_add_obj!(
|
||||||
|
WpDrmLeaseConnectorV1,
|
||||||
|
WpDrmLeaseConnectorV1Id,
|
||||||
|
drm_lease_outputs
|
||||||
|
);
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
pub enum WpDrmLeaseConnectorV1Error {
|
||||||
|
#[error(transparent)]
|
||||||
|
ClientError(Box<ClientError>),
|
||||||
|
}
|
||||||
|
efrom!(WpDrmLeaseConnectorV1Error, ClientError);
|
||||||
228
src/ifs/wp_drm_lease_device_v1.rs
Normal file
228
src/ifs/wp_drm_lease_device_v1.rs
Normal file
|
|
@ -0,0 +1,228 @@
|
||||||
|
use {
|
||||||
|
crate::{
|
||||||
|
backend::DrmDeviceId,
|
||||||
|
client::{Client, ClientCaps, ClientError, CAP_DRM_LEASE},
|
||||||
|
globals::{Global, GlobalName},
|
||||||
|
ifs::{
|
||||||
|
wp_drm_lease_connector_v1::WpDrmLeaseConnectorV1,
|
||||||
|
wp_drm_lease_request_v1::WpDrmLeaseRequestV1,
|
||||||
|
},
|
||||||
|
leaks::Tracker,
|
||||||
|
object::{Object, Version},
|
||||||
|
state::OutputData,
|
||||||
|
utils::{bindings::Bindings, errorfmt::ErrorFmt, oserror::OsError},
|
||||||
|
video::drm::{Drm, DrmError},
|
||||||
|
wire::{wp_drm_lease_device_v1::*, WpDrmLeaseDeviceV1Id},
|
||||||
|
},
|
||||||
|
std::{cell::Cell, rc::Rc},
|
||||||
|
thiserror::Error,
|
||||||
|
uapi::{c, OwnedFd},
|
||||||
|
};
|
||||||
|
|
||||||
|
mod removed_device;
|
||||||
|
|
||||||
|
pub struct WpDrmLeaseDeviceV1Global {
|
||||||
|
pub name: GlobalName,
|
||||||
|
pub device: DrmDeviceId,
|
||||||
|
pub bindings: Rc<Bindings<WpDrmLeaseDeviceV1>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WpDrmLeaseDeviceV1Global {
|
||||||
|
fn bind_(
|
||||||
|
self: Rc<Self>,
|
||||||
|
id: WpDrmLeaseDeviceV1Id,
|
||||||
|
client: &Rc<Client>,
|
||||||
|
version: Version,
|
||||||
|
) -> Result<(), WpDrmLeaseDeviceV1Error> {
|
||||||
|
let obj = Rc::new(WpDrmLeaseDeviceV1 {
|
||||||
|
id,
|
||||||
|
client: client.clone(),
|
||||||
|
tracker: Default::default(),
|
||||||
|
version,
|
||||||
|
bindings: self.bindings.clone(),
|
||||||
|
device: self.device,
|
||||||
|
destroyed: Cell::new(false),
|
||||||
|
});
|
||||||
|
track!(client, obj);
|
||||||
|
client.add_client_obj(&obj)?;
|
||||||
|
if let Some(dev) = client.state.drm_devs.get(&self.device) {
|
||||||
|
if let Some(node) = &dev.devnode {
|
||||||
|
match reopen_card(node) {
|
||||||
|
Ok(f) => obj.send_drm_fd(&f),
|
||||||
|
Err(e) => {
|
||||||
|
log::error!("Could not open master device: {}", ErrorFmt(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for c in dev.connectors.lock().keys() {
|
||||||
|
if let Some(o) = client.state.outputs.get(c) {
|
||||||
|
if o.monitor_info.non_desktop {
|
||||||
|
obj.create_connector(&o);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
obj.send_done();
|
||||||
|
self.bindings.add(client, &obj);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
global_base!(
|
||||||
|
WpDrmLeaseDeviceV1Global,
|
||||||
|
WpDrmLeaseDeviceV1,
|
||||||
|
WpDrmLeaseDeviceV1Error
|
||||||
|
);
|
||||||
|
|
||||||
|
simple_add_global!(WpDrmLeaseDeviceV1Global);
|
||||||
|
|
||||||
|
impl Global for WpDrmLeaseDeviceV1Global {
|
||||||
|
fn singleton(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
fn version(&self) -> u32 {
|
||||||
|
1
|
||||||
|
}
|
||||||
|
|
||||||
|
fn break_loops(&self) {
|
||||||
|
self.bindings.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn required_caps(&self) -> ClientCaps {
|
||||||
|
CAP_DRM_LEASE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct WpDrmLeaseDeviceV1 {
|
||||||
|
pub id: WpDrmLeaseDeviceV1Id,
|
||||||
|
pub client: Rc<Client>,
|
||||||
|
pub tracker: Tracker<Self>,
|
||||||
|
pub version: Version,
|
||||||
|
pub bindings: Rc<Bindings<Self>>,
|
||||||
|
pub device: DrmDeviceId,
|
||||||
|
pub destroyed: Cell<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WpDrmLeaseDeviceV1 {
|
||||||
|
fn detach(&self) {
|
||||||
|
self.destroyed.set(true);
|
||||||
|
self.bindings.remove(&self.client, self);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn create_connector(self: &Rc<Self>, output: &Rc<OutputData>) {
|
||||||
|
let id = match self.client.new_id() {
|
||||||
|
Ok(i) => i,
|
||||||
|
Err(e) => {
|
||||||
|
self.client.error(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let obj = Rc::new(WpDrmLeaseConnectorV1 {
|
||||||
|
id,
|
||||||
|
client: self.client.clone(),
|
||||||
|
tracker: Default::default(),
|
||||||
|
version: self.version,
|
||||||
|
device: self.clone(),
|
||||||
|
connector_id: output.connector.connector.id(),
|
||||||
|
bindings: output.lease_connectors.clone(),
|
||||||
|
});
|
||||||
|
self.client.add_server_obj(&obj);
|
||||||
|
self.send_connector(&obj);
|
||||||
|
obj.send_name(&output.connector.name);
|
||||||
|
if let Some(id) = output.connector.connector.drm_object_id() {
|
||||||
|
obj.send_connector_id(id.0);
|
||||||
|
}
|
||||||
|
obj.send_done();
|
||||||
|
output.lease_connectors.add(&self.client, &obj);
|
||||||
|
}
|
||||||
|
|
||||||
|
fn send_drm_fd(&self, fd: &Rc<OwnedFd>) {
|
||||||
|
self.client.event(DrmFd {
|
||||||
|
self_id: self.id,
|
||||||
|
fd: fd.clone(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
fn send_connector(&self, c: &Rc<WpDrmLeaseConnectorV1>) {
|
||||||
|
self.client.event(Connector {
|
||||||
|
self_id: self.id,
|
||||||
|
id: c.id,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn send_done(&self) {
|
||||||
|
self.client.event(Done { self_id: self.id });
|
||||||
|
}
|
||||||
|
|
||||||
|
fn send_released(&self) {
|
||||||
|
self.client.event(Released { self_id: self.id });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WpDrmLeaseDeviceV1RequestHandler for WpDrmLeaseDeviceV1 {
|
||||||
|
type Error = WpDrmLeaseDeviceV1Error;
|
||||||
|
|
||||||
|
fn create_lease_request(
|
||||||
|
&self,
|
||||||
|
req: CreateLeaseRequest,
|
||||||
|
_slf: &Rc<Self>,
|
||||||
|
) -> Result<(), Self::Error> {
|
||||||
|
let obj = Rc::new(WpDrmLeaseRequestV1 {
|
||||||
|
id: req.id,
|
||||||
|
client: self.client.clone(),
|
||||||
|
tracker: Default::default(),
|
||||||
|
version: self.version,
|
||||||
|
device: self.device,
|
||||||
|
connectors: Default::default(),
|
||||||
|
});
|
||||||
|
self.client.add_client_obj(&obj)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn release(&self, _req: Release, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||||
|
self.detach();
|
||||||
|
self.send_released();
|
||||||
|
self.client.remove_obj(self)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object_base! {
|
||||||
|
self = WpDrmLeaseDeviceV1;
|
||||||
|
version = self.version;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Object for WpDrmLeaseDeviceV1 {
|
||||||
|
fn break_loops(&self) {
|
||||||
|
self.detach();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
simple_add_obj!(WpDrmLeaseDeviceV1);
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
pub enum WpDrmLeaseDeviceV1Error {
|
||||||
|
#[error(transparent)]
|
||||||
|
ClientError(Box<ClientError>),
|
||||||
|
}
|
||||||
|
efrom!(WpDrmLeaseDeviceV1Error, ClientError);
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
enum ReopenError {
|
||||||
|
#[error("Could not open the dev node")]
|
||||||
|
OpenNode(#[source] OsError),
|
||||||
|
#[error("Could not drop DRM master")]
|
||||||
|
DropMaster(#[source] DrmError),
|
||||||
|
}
|
||||||
|
|
||||||
|
fn reopen_card(devnode: &str) -> Result<Rc<OwnedFd>, ReopenError> {
|
||||||
|
let fd = uapi::open(devnode, c::O_RDWR | c::O_CLOEXEC, 0)
|
||||||
|
.map_err(|e| ReopenError::OpenNode(e.into()))?;
|
||||||
|
let fd = Rc::new(fd);
|
||||||
|
let drm = Drm::open_existing(fd.clone());
|
||||||
|
if drm.is_master() {
|
||||||
|
drm.drop_master().map_err(ReopenError::DropMaster)?;
|
||||||
|
}
|
||||||
|
Ok(fd)
|
||||||
|
}
|
||||||
80
src/ifs/wp_drm_lease_device_v1/removed_device.rs
Normal file
80
src/ifs/wp_drm_lease_device_v1/removed_device.rs
Normal file
|
|
@ -0,0 +1,80 @@
|
||||||
|
use {
|
||||||
|
crate::{
|
||||||
|
backend::DrmDeviceId,
|
||||||
|
client::{Client, ClientCaps, ClientError, CAP_DRM_LEASE},
|
||||||
|
globals::{Global, GlobalName, RemovableWaylandGlobal},
|
||||||
|
ifs::wp_drm_lease_device_v1::{WpDrmLeaseDeviceV1, WpDrmLeaseDeviceV1Global},
|
||||||
|
object::Version,
|
||||||
|
utils::bindings::Bindings,
|
||||||
|
wire::WpDrmLeaseDeviceV1Id,
|
||||||
|
},
|
||||||
|
std::{cell::Cell, rc::Rc},
|
||||||
|
thiserror::Error,
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RemovedWpDrmLeaseDeviceV1Global {
|
||||||
|
name: GlobalName,
|
||||||
|
bindings: Rc<Bindings<WpDrmLeaseDeviceV1>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RemovedWpDrmLeaseDeviceV1Global {
|
||||||
|
fn bind_(
|
||||||
|
self: Rc<Self>,
|
||||||
|
id: WpDrmLeaseDeviceV1Id,
|
||||||
|
client: &Rc<Client>,
|
||||||
|
version: Version,
|
||||||
|
) -> Result<(), RemovedWpDrmLeaseDeviceV1Error> {
|
||||||
|
let dev = Rc::new(WpDrmLeaseDeviceV1 {
|
||||||
|
id,
|
||||||
|
client: client.clone(),
|
||||||
|
tracker: Default::default(),
|
||||||
|
version,
|
||||||
|
bindings: self.bindings.clone(),
|
||||||
|
device: DrmDeviceId::from_raw(0),
|
||||||
|
destroyed: Cell::new(false),
|
||||||
|
});
|
||||||
|
track!(client, dev);
|
||||||
|
client.add_client_obj(&dev)?;
|
||||||
|
dev.send_done();
|
||||||
|
dev.bindings.add(client, &dev);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
global_base!(
|
||||||
|
RemovedWpDrmLeaseDeviceV1Global,
|
||||||
|
WpDrmLeaseDeviceV1,
|
||||||
|
RemovedWpDrmLeaseDeviceV1Error
|
||||||
|
);
|
||||||
|
|
||||||
|
simple_add_global!(RemovedWpDrmLeaseDeviceV1Global);
|
||||||
|
|
||||||
|
impl Global for RemovedWpDrmLeaseDeviceV1Global {
|
||||||
|
fn singleton(&self) -> bool {
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
fn version(&self) -> u32 {
|
||||||
|
1
|
||||||
|
}
|
||||||
|
|
||||||
|
fn required_caps(&self) -> ClientCaps {
|
||||||
|
CAP_DRM_LEASE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl RemovableWaylandGlobal for WpDrmLeaseDeviceV1Global {
|
||||||
|
fn create_replacement(&self) -> Rc<dyn Global> {
|
||||||
|
Rc::new(RemovedWpDrmLeaseDeviceV1Global {
|
||||||
|
name: self.name,
|
||||||
|
bindings: Default::default(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
pub enum RemovedWpDrmLeaseDeviceV1Error {
|
||||||
|
#[error(transparent)]
|
||||||
|
ClientError(Box<ClientError>),
|
||||||
|
}
|
||||||
|
efrom!(RemovedWpDrmLeaseDeviceV1Error, ClientError);
|
||||||
84
src/ifs/wp_drm_lease_request_v1.rs
Normal file
84
src/ifs/wp_drm_lease_request_v1.rs
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
use {
|
||||||
|
crate::{
|
||||||
|
backend::{ConnectorId, DrmDeviceId},
|
||||||
|
client::{Client, ClientError},
|
||||||
|
ifs::wp_drm_lease_v1::{WpDrmLeaseV1, WpDrmLeaseV1Lessee},
|
||||||
|
leaks::Tracker,
|
||||||
|
object::{Object, Version},
|
||||||
|
utils::copyhashmap::CopyHashMap,
|
||||||
|
wire::{wp_drm_lease_request_v1::*, WpDrmLeaseConnectorV1Id, WpDrmLeaseRequestV1Id},
|
||||||
|
},
|
||||||
|
std::{cell::Cell, rc::Rc},
|
||||||
|
thiserror::Error,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub struct WpDrmLeaseRequestV1 {
|
||||||
|
pub id: WpDrmLeaseRequestV1Id,
|
||||||
|
pub client: Rc<Client>,
|
||||||
|
pub tracker: Tracker<Self>,
|
||||||
|
pub version: Version,
|
||||||
|
pub device: DrmDeviceId,
|
||||||
|
pub connectors: CopyHashMap<WpDrmLeaseConnectorV1Id, ConnectorId>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WpDrmLeaseRequestV1RequestHandler for WpDrmLeaseRequestV1 {
|
||||||
|
type Error = WpDrmLeaseRequestV1Error;
|
||||||
|
|
||||||
|
fn request_connector(&self, req: RequestConnector, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||||
|
let c = self.client.lookup(req.connector)?;
|
||||||
|
if self.device != c.device.device {
|
||||||
|
return Err(WpDrmLeaseRequestV1Error::MismatchedDevice(c.id));
|
||||||
|
}
|
||||||
|
if self.connectors.contains(&c.id) {
|
||||||
|
return Err(WpDrmLeaseRequestV1Error::RepeatedDevice(c.id));
|
||||||
|
}
|
||||||
|
self.connectors.set(c.id, c.connector_id);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn submit(&self, req: Submit, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||||
|
self.client.remove_obj(self)?;
|
||||||
|
let obj = Rc::new(WpDrmLeaseV1 {
|
||||||
|
id: req.id,
|
||||||
|
client: self.client.clone(),
|
||||||
|
tracker: Default::default(),
|
||||||
|
version: self.version,
|
||||||
|
finished: Cell::new(false),
|
||||||
|
lease: Default::default(),
|
||||||
|
});
|
||||||
|
self.client.add_client_obj(&obj)?;
|
||||||
|
if self.connectors.is_empty() {
|
||||||
|
return Err(WpDrmLeaseRequestV1Error::EmptyLease);
|
||||||
|
}
|
||||||
|
let Some(dev) = self.client.state.drm_devs.get(&self.device) else {
|
||||||
|
obj.send_finished();
|
||||||
|
return Ok(());
|
||||||
|
};
|
||||||
|
let lessee = Rc::new(WpDrmLeaseV1Lessee { obj });
|
||||||
|
let connectors: Vec<_> = self.connectors.lock().values().copied().collect();
|
||||||
|
dev.dev.clone().create_lease(lessee, &connectors);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object_base! {
|
||||||
|
self = WpDrmLeaseRequestV1;
|
||||||
|
version = self.version;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Object for WpDrmLeaseRequestV1 {}
|
||||||
|
|
||||||
|
simple_add_obj!(WpDrmLeaseRequestV1);
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
pub enum WpDrmLeaseRequestV1Error {
|
||||||
|
#[error(transparent)]
|
||||||
|
ClientError(Box<ClientError>),
|
||||||
|
#[error("Connector {0} does not belong to this device")]
|
||||||
|
MismatchedDevice(WpDrmLeaseConnectorV1Id),
|
||||||
|
#[error("Connector {0} is already part of this request")]
|
||||||
|
RepeatedDevice(WpDrmLeaseConnectorV1Id),
|
||||||
|
#[error("Lease request is empty")]
|
||||||
|
EmptyLease,
|
||||||
|
}
|
||||||
|
efrom!(WpDrmLeaseRequestV1Error, ClientError);
|
||||||
92
src/ifs/wp_drm_lease_v1.rs
Normal file
92
src/ifs/wp_drm_lease_v1.rs
Normal file
|
|
@ -0,0 +1,92 @@
|
||||||
|
use {
|
||||||
|
crate::{
|
||||||
|
backend::{BackendDrmLease, BackendDrmLessee},
|
||||||
|
client::{Client, ClientError},
|
||||||
|
leaks::Tracker,
|
||||||
|
object::{Object, Version},
|
||||||
|
utils::clonecell::CloneCell,
|
||||||
|
wire::{wp_drm_lease_v1::*, WpDrmLeaseV1Id},
|
||||||
|
},
|
||||||
|
std::{cell::Cell, rc::Rc},
|
||||||
|
thiserror::Error,
|
||||||
|
uapi::OwnedFd,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub struct WpDrmLeaseV1Lessee {
|
||||||
|
pub obj: Rc<WpDrmLeaseV1>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl BackendDrmLessee for WpDrmLeaseV1Lessee {
|
||||||
|
fn created(&self, lease: Rc<dyn BackendDrmLease>) {
|
||||||
|
if !self.obj.finished.get() {
|
||||||
|
self.obj.send_lease_fd(lease.fd());
|
||||||
|
self.obj.lease.set(Some(lease));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Drop for WpDrmLeaseV1Lessee {
|
||||||
|
fn drop(&mut self) {
|
||||||
|
if !self.obj.finished.get() {
|
||||||
|
self.obj.detach();
|
||||||
|
self.obj.send_finished();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct WpDrmLeaseV1 {
|
||||||
|
pub id: WpDrmLeaseV1Id,
|
||||||
|
pub client: Rc<Client>,
|
||||||
|
pub tracker: Tracker<Self>,
|
||||||
|
pub version: Version,
|
||||||
|
pub finished: Cell<bool>,
|
||||||
|
pub lease: CloneCell<Option<Rc<dyn BackendDrmLease>>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WpDrmLeaseV1 {
|
||||||
|
fn detach(&self) {
|
||||||
|
self.finished.set(true);
|
||||||
|
self.lease.take();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn send_lease_fd(&self, fd: &Rc<OwnedFd>) {
|
||||||
|
self.client.event(LeaseFd {
|
||||||
|
self_id: self.id,
|
||||||
|
leased_fd: fd.clone(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn send_finished(&self) {
|
||||||
|
self.client.event(Finished { self_id: self.id });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl WpDrmLeaseV1RequestHandler for WpDrmLeaseV1 {
|
||||||
|
type Error = WpDrmLeaseV1Error;
|
||||||
|
|
||||||
|
fn destroy(&self, _req: Destroy, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||||
|
self.detach();
|
||||||
|
self.client.remove_obj(self)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
object_base! {
|
||||||
|
self = WpDrmLeaseV1;
|
||||||
|
version = self.version;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Object for WpDrmLeaseV1 {
|
||||||
|
fn break_loops(&self) {
|
||||||
|
self.detach();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
simple_add_obj!(WpDrmLeaseV1);
|
||||||
|
|
||||||
|
#[derive(Debug, Error)]
|
||||||
|
pub enum WpDrmLeaseV1Error {
|
||||||
|
#[error(transparent)]
|
||||||
|
ClientError(Box<ClientError>),
|
||||||
|
}
|
||||||
|
efrom!(WpDrmLeaseV1Error, ClientError);
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
client::{Client, ClientCaps, ClientError},
|
client::{Client, ClientError, CAPS_DEFAULT_SANDBOXED},
|
||||||
leaks::Tracker,
|
leaks::Tracker,
|
||||||
object::{Object, Version},
|
object::{Object, Version},
|
||||||
wire::{wp_security_context_v1::*, WpSecurityContextV1Id},
|
wire::{wp_security_context_v1::*, WpSecurityContextV1Id},
|
||||||
|
|
@ -80,7 +80,7 @@ impl WpSecurityContextV1RequestHandler for WpSecurityContextV1 {
|
||||||
fn commit(&self, _req: Commit, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
fn commit(&self, _req: Commit, _slf: &Rc<Self>) -> Result<(), Self::Error> {
|
||||||
self.check_committed()?;
|
self.check_committed()?;
|
||||||
self.committed.set(true);
|
self.committed.set(true);
|
||||||
let caps = ClientCaps::none() & self.client.bounding_caps;
|
let caps = CAPS_DEFAULT_SANDBOXED & self.client.bounding_caps;
|
||||||
self.client.state.security_context_acceptors.spawn(
|
self.client.state.security_context_acceptors.spawn(
|
||||||
&self.client.state,
|
&self.client.state,
|
||||||
self.sandbox_engine.take(),
|
self.sandbox_engine.take(),
|
||||||
|
|
|
||||||
|
|
@ -65,9 +65,9 @@ impl ZwlrLayerShellV1RequestHandler for ZwlrLayerShellV1 {
|
||||||
break 'get_output output.global.opt.clone();
|
break 'get_output output.global.opt.clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let outputs = self.client.state.outputs.lock();
|
let outputs = self.client.state.root.outputs.lock();
|
||||||
if let Some(output) = outputs.values().next() {
|
if let Some(output) = outputs.values().next() {
|
||||||
break 'get_output output.node.global.opt.clone();
|
break 'get_output output.global.opt.clone();
|
||||||
}
|
}
|
||||||
return Err(ZwlrLayerShellV1Error::NoOutputs);
|
return Err(ZwlrLayerShellV1Error::NoOutputs);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,7 @@ impl TestBackend {
|
||||||
initial_mode: mode,
|
initial_mode: mode,
|
||||||
width_mm: 80,
|
width_mm: 80,
|
||||||
height_mm: 60,
|
height_mm: 60,
|
||||||
|
non_desktop: false,
|
||||||
};
|
};
|
||||||
Self {
|
Self {
|
||||||
state: state.clone(),
|
state: state.clone(),
|
||||||
|
|
|
||||||
|
|
@ -109,9 +109,9 @@ impl TestRun {
|
||||||
self.backend.install_default()?;
|
self.backend.install_default()?;
|
||||||
let seat = self.get_seat("default")?;
|
let seat = self.get_seat("default")?;
|
||||||
self.state.eng.yield_now().await;
|
self.state.eng.yield_now().await;
|
||||||
let output = match self.state.outputs.lock().values().next() {
|
let output = match self.state.root.outputs.lock().values().next() {
|
||||||
None => bail!("No output"),
|
None => bail!("No output"),
|
||||||
Some(d) => d.node.clone(),
|
Some(d) => d.clone(),
|
||||||
};
|
};
|
||||||
self.cfg
|
self.cfg
|
||||||
.set_input_device_seat(self.backend.default_kb.common.id, seat.id())?;
|
.set_input_device_seat(self.backend.default_kb.common.id, seat.id())?;
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ async fn test(run: Rc<TestRun>) -> TestResult {
|
||||||
},
|
},
|
||||||
width_mm: 0,
|
width_mm: 0,
|
||||||
height_mm: 0,
|
height_mm: 0,
|
||||||
|
non_desktop: false,
|
||||||
};
|
};
|
||||||
run.backend
|
run.backend
|
||||||
.state
|
.state
|
||||||
|
|
|
||||||
15
src/state.rs
15
src/state.rs
|
|
@ -40,6 +40,8 @@ use {
|
||||||
zwp_input_popup_surface_v2::ZwpInputPopupSurfaceV2,
|
zwp_input_popup_surface_v2::ZwpInputPopupSurfaceV2,
|
||||||
NoneSurfaceExt, WlSurface,
|
NoneSurfaceExt, WlSurface,
|
||||||
},
|
},
|
||||||
|
wp_drm_lease_connector_v1::WpDrmLeaseConnectorV1,
|
||||||
|
wp_drm_lease_device_v1::WpDrmLeaseDeviceV1Global,
|
||||||
wp_linux_drm_syncobj_manager_v1::WpLinuxDrmSyncobjManagerV1Global,
|
wp_linux_drm_syncobj_manager_v1::WpLinuxDrmSyncobjManagerV1Global,
|
||||||
zwlr_screencopy_frame_v1::ZwlrScreencopyFrameV1,
|
zwlr_screencopy_frame_v1::ZwlrScreencopyFrameV1,
|
||||||
zwp_linux_dmabuf_feedback_v1::ZwpLinuxDmabufFeedbackV1,
|
zwp_linux_dmabuf_feedback_v1::ZwpLinuxDmabufFeedbackV1,
|
||||||
|
|
@ -59,8 +61,8 @@ use {
|
||||||
WorkspaceNode,
|
WorkspaceNode,
|
||||||
},
|
},
|
||||||
utils::{
|
utils::{
|
||||||
activation_token::ActivationToken, asyncevent::AsyncEvent, clonecell::CloneCell,
|
activation_token::ActivationToken, asyncevent::AsyncEvent, bindings::Bindings,
|
||||||
copyhashmap::CopyHashMap, errorfmt::ErrorFmt, fdcloser::FdCloser,
|
clonecell::CloneCell, copyhashmap::CopyHashMap, errorfmt::ErrorFmt, fdcloser::FdCloser,
|
||||||
linkedlist::LinkedList, numcell::NumCell, queue::AsyncQueue, refcounted::RefCounted,
|
linkedlist::LinkedList, numcell::NumCell, queue::AsyncQueue, refcounted::RefCounted,
|
||||||
run_toplevel::RunToplevel,
|
run_toplevel::RunToplevel,
|
||||||
},
|
},
|
||||||
|
|
@ -268,7 +270,8 @@ pub struct ConnectorData {
|
||||||
pub struct OutputData {
|
pub struct OutputData {
|
||||||
pub connector: Rc<ConnectorData>,
|
pub connector: Rc<ConnectorData>,
|
||||||
pub monitor_info: MonitorInfo,
|
pub monitor_info: MonitorInfo,
|
||||||
pub node: Rc<OutputNode>,
|
pub node: Option<Rc<OutputNode>>,
|
||||||
|
pub lease_connectors: Rc<Bindings<WpDrmLeaseConnectorV1>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct DrmDevData {
|
pub struct DrmDevData {
|
||||||
|
|
@ -280,6 +283,7 @@ pub struct DrmDevData {
|
||||||
pub vendor: Option<String>,
|
pub vendor: Option<String>,
|
||||||
pub model: Option<String>,
|
pub model: Option<String>,
|
||||||
pub pci_id: Option<PciId>,
|
pub pci_id: Option<PciId>,
|
||||||
|
pub lease_global: Rc<WpDrmLeaseDeviceV1Global>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DrmDevData {
|
impl DrmDevData {
|
||||||
|
|
@ -731,8 +735,9 @@ impl State {
|
||||||
connector.handler.take();
|
connector.handler.take();
|
||||||
connector.async_event.clear();
|
connector.async_event.clear();
|
||||||
}
|
}
|
||||||
for (_, output) in self.outputs.lock().drain() {
|
self.outputs.clear();
|
||||||
output.node.clear();
|
for output in self.root.outputs.lock().values() {
|
||||||
|
output.clear();
|
||||||
}
|
}
|
||||||
self.dbus.clear();
|
self.dbus.clear();
|
||||||
self.pending_container_layout.clear();
|
self.pending_container_layout.clear();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
backend::{Connector, ConnectorEvent, ConnectorId, MonitorInfo},
|
backend::{Connector, ConnectorEvent, ConnectorId, MonitorInfo},
|
||||||
|
globals::GlobalName,
|
||||||
ifs::wl_output::{OutputId, PersistentOutputState, WlOutputGlobal},
|
ifs::wl_output::{OutputId, PersistentOutputState, WlOutputGlobal},
|
||||||
state::{ConnectorData, OutputData, State},
|
state::{ConnectorData, OutputData, State},
|
||||||
tree::{move_ws_to_output, OutputNode, OutputRenderData, WsMoveConfig},
|
tree::{move_ws_to_output, OutputNode, OutputRenderData, WsMoveConfig},
|
||||||
|
|
@ -70,6 +71,9 @@ impl ConnectorHandler {
|
||||||
}
|
}
|
||||||
self.data.async_event.triggered().await;
|
self.data.async_event.triggered().await;
|
||||||
}
|
}
|
||||||
|
if let Some(dev) = &self.data.drm_dev {
|
||||||
|
dev.connectors.remove(&self.id);
|
||||||
|
}
|
||||||
if let Some(config) = self.state.config.get() {
|
if let Some(config) = self.state.config.get() {
|
||||||
config.del_connector(self.id);
|
config.del_connector(self.id);
|
||||||
}
|
}
|
||||||
|
|
@ -87,6 +91,21 @@ impl ConnectorHandler {
|
||||||
model: info.product.clone(),
|
model: info.product.clone(),
|
||||||
serial_number: info.serial_number.clone(),
|
serial_number: info.serial_number.clone(),
|
||||||
});
|
});
|
||||||
|
if info.non_desktop {
|
||||||
|
self.handle_non_desktop_connected(info).await;
|
||||||
|
} else {
|
||||||
|
self.handle_desktop_connected(info, name, output_id).await;
|
||||||
|
}
|
||||||
|
self.data.connected.set(false);
|
||||||
|
log::info!("Connector {} disconnected", self.data.connector.kernel_id());
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn handle_desktop_connected(
|
||||||
|
&self,
|
||||||
|
info: MonitorInfo,
|
||||||
|
name: GlobalName,
|
||||||
|
output_id: Rc<OutputId>,
|
||||||
|
) {
|
||||||
let desired_state = match self.state.persistent_output_states.get(&output_id) {
|
let desired_state = match self.state.persistent_output_states.get(&output_id) {
|
||||||
Some(ds) => ds,
|
Some(ds) => ds,
|
||||||
_ => {
|
_ => {
|
||||||
|
|
@ -155,13 +174,17 @@ impl ConnectorHandler {
|
||||||
let output_data = Rc::new(OutputData {
|
let output_data = Rc::new(OutputData {
|
||||||
connector: self.data.clone(),
|
connector: self.data.clone(),
|
||||||
monitor_info: info,
|
monitor_info: info,
|
||||||
node: on.clone(),
|
node: Some(on.clone()),
|
||||||
|
lease_connectors: Default::default(),
|
||||||
});
|
});
|
||||||
self.state.outputs.set(self.id, output_data);
|
self.state.outputs.set(self.id, output_data);
|
||||||
|
on.schedule_update_render_data();
|
||||||
|
self.state.root.outputs.set(self.id, on.clone());
|
||||||
|
self.state.root.update_extents();
|
||||||
global.opt.node.set(Some(on.clone()));
|
global.opt.node.set(Some(on.clone()));
|
||||||
global.opt.global.set(Some(global.clone()));
|
global.opt.global.set(Some(global.clone()));
|
||||||
let mut ws_to_move = VecDeque::new();
|
let mut ws_to_move = VecDeque::new();
|
||||||
if self.state.outputs.len() == 1 {
|
if self.state.root.outputs.len() == 1 {
|
||||||
let seats = self.state.globals.seats.lock();
|
let seats = self.state.globals.seats.lock();
|
||||||
let pos = global.pos.get();
|
let pos = global.pos.get();
|
||||||
let x = (pos.x1() + pos.x2()) / 2;
|
let x = (pos.x1() + pos.x2()) / 2;
|
||||||
|
|
@ -177,11 +200,11 @@ impl ConnectorHandler {
|
||||||
ws_to_move.push_back(ws);
|
ws_to_move.push_back(ws);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for source in self.state.outputs.lock().values() {
|
for source in self.state.root.outputs.lock().values() {
|
||||||
if source.node.id == on.id {
|
if source.id == on.id {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for ws in source.node.workspaces.iter() {
|
for ws in source.workspaces.iter() {
|
||||||
if ws.is_dummy {
|
if ws.is_dummy {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -203,9 +226,6 @@ impl ConnectorHandler {
|
||||||
if let Some(config) = self.state.config.get() {
|
if let Some(config) = self.state.config.get() {
|
||||||
config.connector_connected(self.id);
|
config.connector_connected(self.id);
|
||||||
}
|
}
|
||||||
on.schedule_update_render_data();
|
|
||||||
self.state.root.outputs.set(self.id, on.clone());
|
|
||||||
self.state.root.update_extents();
|
|
||||||
self.state.add_global(&global);
|
self.state.add_global(&global);
|
||||||
self.state.tree_changed();
|
self.state.tree_changed();
|
||||||
'outer: loop {
|
'outer: loop {
|
||||||
|
|
@ -224,7 +244,6 @@ impl ConnectorHandler {
|
||||||
}
|
}
|
||||||
self.data.async_event.triggered().await;
|
self.data.async_event.triggered().await;
|
||||||
}
|
}
|
||||||
log::info!("Connector {} disconnected", self.data.connector.kernel_id());
|
|
||||||
if let Some(config) = self.state.config.get() {
|
if let Some(config) = self.state.config.get() {
|
||||||
config.connector_disconnected(self.id);
|
config.connector_disconnected(self.id);
|
||||||
}
|
}
|
||||||
|
|
@ -242,7 +261,6 @@ impl ConnectorHandler {
|
||||||
global.destroyed.set(true);
|
global.destroyed.set(true);
|
||||||
self.state.root.outputs.remove(&self.id);
|
self.state.root.outputs.remove(&self.id);
|
||||||
self.state.root.update_extents();
|
self.state.root.update_extents();
|
||||||
self.data.connected.set(false);
|
|
||||||
self.state.outputs.remove(&self.id);
|
self.state.outputs.remove(&self.id);
|
||||||
on.lock_surface.take();
|
on.lock_surface.take();
|
||||||
{
|
{
|
||||||
|
|
@ -255,8 +273,8 @@ impl ConnectorHandler {
|
||||||
surface.send_closed();
|
surface.send_closed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let target = match self.state.outputs.lock().values().next() {
|
let target = match self.state.root.outputs.lock().values().next() {
|
||||||
Some(o) => o.node.clone(),
|
Some(o) => o.clone(),
|
||||||
_ => self.state.dummy_output.get().unwrap(),
|
_ => self.state.dummy_output.get().unwrap(),
|
||||||
};
|
};
|
||||||
for ws in on.workspaces.iter() {
|
for ws in on.workspaces.iter() {
|
||||||
|
|
@ -276,13 +294,56 @@ impl ConnectorHandler {
|
||||||
seat.set_position((tpos.x1() + tpos.x2()) / 2, (tpos.y1() + tpos.y2()) / 2);
|
seat.set_position((tpos.x1() + tpos.x2()) / 2, (tpos.y1() + tpos.y2()) / 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(dev) = &self.data.drm_dev {
|
|
||||||
dev.connectors.remove(&self.id);
|
|
||||||
}
|
|
||||||
self.state
|
self.state
|
||||||
.remove_output_scale(on.global.persistent.scale.get());
|
.remove_output_scale(on.global.persistent.scale.get());
|
||||||
let _ = self.state.remove_global(&*global);
|
let _ = self.state.remove_global(&*global);
|
||||||
self.state.tree_changed();
|
self.state.tree_changed();
|
||||||
self.state.damage();
|
self.state.damage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn handle_non_desktop_connected(&self, monitor_info: MonitorInfo) {
|
||||||
|
let output_data = Rc::new(OutputData {
|
||||||
|
connector: self.data.clone(),
|
||||||
|
monitor_info,
|
||||||
|
node: None,
|
||||||
|
lease_connectors: Default::default(),
|
||||||
|
});
|
||||||
|
self.state.outputs.set(self.id, output_data.clone());
|
||||||
|
let advertise = || {
|
||||||
|
if let Some(dev) = &self.data.drm_dev {
|
||||||
|
for binding in dev.lease_global.bindings.lock().values() {
|
||||||
|
binding.create_connector(&output_data);
|
||||||
|
binding.send_done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let withdraw = || {
|
||||||
|
for (_, con) in output_data.lease_connectors.lock().drain() {
|
||||||
|
con.send_withdrawn();
|
||||||
|
if !con.device.destroyed.get() {
|
||||||
|
con.device.send_done();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
advertise();
|
||||||
|
if let Some(config) = self.state.config.get() {
|
||||||
|
config.connector_connected(self.id);
|
||||||
|
}
|
||||||
|
'outer: loop {
|
||||||
|
while let Some(event) = self.data.connector.event() {
|
||||||
|
match event {
|
||||||
|
ConnectorEvent::Disconnected => break 'outer,
|
||||||
|
ConnectorEvent::Available => advertise(),
|
||||||
|
ConnectorEvent::Unavailable => withdraw(),
|
||||||
|
ev => unreachable!("received unexpected event {:?}", ev),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.data.async_event.triggered().await;
|
||||||
|
}
|
||||||
|
withdraw();
|
||||||
|
self.state.outputs.remove(&self.id);
|
||||||
|
if let Some(config) = self.state.config.get() {
|
||||||
|
config.connector_disconnected(self.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
use {
|
use {
|
||||||
crate::{
|
crate::{
|
||||||
backend::{BackendDrmDevice, DrmDeviceId, DrmEvent},
|
backend::{BackendDrmDevice, DrmDeviceId, DrmEvent},
|
||||||
|
ifs::wp_drm_lease_device_v1::WpDrmLeaseDeviceV1Global,
|
||||||
state::{DrmDevData, State},
|
state::{DrmDevData, State},
|
||||||
tasks::udev_utils::udev_props,
|
tasks::udev_utils::udev_props,
|
||||||
utils::asyncevent::AsyncEvent,
|
utils::asyncevent::AsyncEvent,
|
||||||
|
|
@ -11,6 +12,12 @@ use {
|
||||||
pub fn handle(state: &Rc<State>, dev: Rc<dyn BackendDrmDevice>) {
|
pub fn handle(state: &Rc<State>, dev: Rc<dyn BackendDrmDevice>) {
|
||||||
let id = dev.id();
|
let id = dev.id();
|
||||||
let props = udev_props(dev.dev_t(), 1);
|
let props = udev_props(dev.dev_t(), 1);
|
||||||
|
let lease_global = Rc::new(WpDrmLeaseDeviceV1Global {
|
||||||
|
name: state.globals.name(),
|
||||||
|
device: id,
|
||||||
|
bindings: Default::default(),
|
||||||
|
});
|
||||||
|
state.add_global(&lease_global);
|
||||||
let data = Rc::new(DrmDevData {
|
let data = Rc::new(DrmDevData {
|
||||||
dev: dev.clone(),
|
dev: dev.clone(),
|
||||||
handler: Cell::new(None),
|
handler: Cell::new(None),
|
||||||
|
|
@ -20,6 +27,7 @@ pub fn handle(state: &Rc<State>, dev: Rc<dyn BackendDrmDevice>) {
|
||||||
vendor: props.vendor,
|
vendor: props.vendor,
|
||||||
model: props.model,
|
model: props.model,
|
||||||
pci_id: props.pci_id,
|
pci_id: props.pci_id,
|
||||||
|
lease_global,
|
||||||
});
|
});
|
||||||
let oh = DrvDevHandler {
|
let oh = DrvDevHandler {
|
||||||
id,
|
id,
|
||||||
|
|
@ -66,6 +74,8 @@ impl DrvDevHandler {
|
||||||
if let Some(config) = self.state.config.get() {
|
if let Some(config) = self.state.config.get() {
|
||||||
config.del_drm_dev(self.id);
|
config.del_drm_dev(self.id);
|
||||||
}
|
}
|
||||||
|
self.data.lease_global.bindings.clear();
|
||||||
|
let _ = self.state.remove_global(&*self.data.lease_global);
|
||||||
self.data.handler.set(None);
|
self.data.handler.set(None);
|
||||||
self.state.drm_devs.remove(&self.id);
|
self.state.drm_devs.remove(&self.id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
pub mod activation_token;
|
pub mod activation_token;
|
||||||
pub mod array;
|
pub mod array;
|
||||||
pub mod asyncevent;
|
pub mod asyncevent;
|
||||||
|
pub mod bindings;
|
||||||
pub mod bitfield;
|
pub mod bitfield;
|
||||||
pub mod bitflags;
|
pub mod bitflags;
|
||||||
pub mod buf;
|
pub mod buf;
|
||||||
|
|
|
||||||
39
src/utils/bindings.rs
Normal file
39
src/utils/bindings.rs
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
use {
|
||||||
|
crate::{
|
||||||
|
client::{Client, ClientId},
|
||||||
|
object::{Object, ObjectId},
|
||||||
|
utils::copyhashmap::{CopyHashMap, Locked},
|
||||||
|
},
|
||||||
|
std::rc::Rc,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub struct Bindings<P> {
|
||||||
|
bindings: CopyHashMap<(ClientId, ObjectId), Rc<P>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<P> Default for Bindings<P> {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
bindings: Default::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<P: Object> Bindings<P> {
|
||||||
|
pub fn add(&self, client: &Client, obj: &Rc<P>) {
|
||||||
|
let prev = self.bindings.set((client.id, obj.id()), obj.clone());
|
||||||
|
assert!(prev.is_none());
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn remove(&self, client: &Client, obj: &P) {
|
||||||
|
self.bindings.remove(&(client.id, obj.id()));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn clear(&self) {
|
||||||
|
self.bindings.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn lock(&self) -> Locked<(ClientId, ObjectId), Rc<P>> {
|
||||||
|
self.bindings.lock()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -163,7 +163,7 @@ static ERRORS: Lazy<&'static [Option<&'static str>]> = Lazy::new(|| {
|
||||||
res.leak()
|
res.leak()
|
||||||
});
|
});
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug, Eq, PartialEq)]
|
||||||
pub struct OsError(pub c::c_int);
|
pub struct OsError(pub c::c_int);
|
||||||
|
|
||||||
impl From<Errno> for OsError {
|
impl From<Errno> for OsError {
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ use {
|
||||||
bstr::{BString, ByteSlice},
|
bstr::{BString, ByteSlice},
|
||||||
indexmap::IndexSet,
|
indexmap::IndexSet,
|
||||||
std::{
|
std::{
|
||||||
cell::RefCell,
|
cell::{Cell, RefCell},
|
||||||
ffi::CString,
|
ffi::CString,
|
||||||
fmt::{Debug, Display, Formatter},
|
fmt::{Debug, Display, Formatter},
|
||||||
mem::{self, MaybeUninit},
|
mem::{self, MaybeUninit},
|
||||||
|
|
@ -40,8 +40,8 @@ use crate::{
|
||||||
video::{
|
video::{
|
||||||
dmabuf::DmaBuf,
|
dmabuf::DmaBuf,
|
||||||
drm::sys::{
|
drm::sys::{
|
||||||
drm_format_modifier, drm_format_modifier_blob, get_version, DRM_CAP_CURSOR_HEIGHT,
|
auth_magic, drm_format_modifier, drm_format_modifier_blob, drop_master, get_version,
|
||||||
DRM_CAP_CURSOR_WIDTH, FORMAT_BLOB_CURRENT,
|
revoke_lease, DRM_CAP_CURSOR_HEIGHT, DRM_CAP_CURSOR_WIDTH, FORMAT_BLOB_CURRENT,
|
||||||
},
|
},
|
||||||
Modifier, INVALID_MODIFIER,
|
Modifier, INVALID_MODIFIER,
|
||||||
},
|
},
|
||||||
|
|
@ -137,6 +137,10 @@ pub enum DrmError {
|
||||||
Merge(#[source] OsError),
|
Merge(#[source] OsError),
|
||||||
#[error("Could not import a sync file into a sync obj")]
|
#[error("Could not import a sync file into a sync obj")]
|
||||||
ImportSyncFile(#[source] OsError),
|
ImportSyncFile(#[source] OsError),
|
||||||
|
#[error("Could not create a lease")]
|
||||||
|
CreateLease(#[source] OsError),
|
||||||
|
#[error("Could not drop DRM master")]
|
||||||
|
DropMaster(#[source] OsError),
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_node_name(fd: c::c_int) -> Result<Ustring, DrmError> {
|
fn render_node_name(fd: c::c_int) -> Result<Ustring, DrmError> {
|
||||||
|
|
@ -173,7 +177,6 @@ pub struct Drm {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drm {
|
impl Drm {
|
||||||
#[cfg_attr(not(feature = "it"), allow(dead_code))]
|
|
||||||
pub fn open_existing(fd: Rc<OwnedFd>) -> Self {
|
pub fn open_existing(fd: Rc<OwnedFd>) -> Self {
|
||||||
Self { fd }
|
Self { fd }
|
||||||
}
|
}
|
||||||
|
|
@ -211,6 +214,14 @@ impl Drm {
|
||||||
pub fn version(&self) -> Result<DrmVersion, DrmError> {
|
pub fn version(&self) -> Result<DrmVersion, DrmError> {
|
||||||
get_version(self.fd.raw()).map_err(DrmError::Version)
|
get_version(self.fd.raw()).map_err(DrmError::Version)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn drop_master(&self) -> Result<(), DrmError> {
|
||||||
|
drop_master(self.fd.raw()).map_err(DrmError::DropMaster)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn is_master(&self) -> bool {
|
||||||
|
auth_magic(self.fd.raw(), 0) != Err(OsError(c::EACCES))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct InFormat {
|
pub struct InFormat {
|
||||||
|
|
@ -242,6 +253,36 @@ impl Deref for DrmMaster {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct DrmLease {
|
||||||
|
drm_fd: Rc<OwnedFd>,
|
||||||
|
lessee_id: u32,
|
||||||
|
lessee_fd: Rc<OwnedFd>,
|
||||||
|
revoked: Cell<bool>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl DrmLease {
|
||||||
|
pub fn lessee_fd(&self) -> &Rc<OwnedFd> {
|
||||||
|
&self.lessee_fd
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn try_revoke(&self) -> bool {
|
||||||
|
if self.revoked.get() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
match revoke_lease(self.drm_fd.raw(), self.lessee_id) {
|
||||||
|
Ok(_) => {
|
||||||
|
log::info!("Revoked lease {}/{}", self.drm_fd.raw(), self.lessee_id);
|
||||||
|
self.revoked.set(true);
|
||||||
|
true
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
log::error!("Could not revoke lease: {}", ErrorFmt(e));
|
||||||
|
false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl DrmMaster {
|
impl DrmMaster {
|
||||||
pub fn new(ring: &Rc<IoUring>, fd: Rc<OwnedFd>) -> Self {
|
pub fn new(ring: &Rc<IoUring>, fd: Rc<OwnedFd>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
@ -516,6 +557,18 @@ impl DrmMaster {
|
||||||
}
|
}
|
||||||
Ok(self.events.pop())
|
Ok(self.events.pop())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn lease(&self, objs: &[u32]) -> Result<DrmLease, DrmError> {
|
||||||
|
let (fd, lessee_id) =
|
||||||
|
create_lease(self.raw(), objs, c::O_CLOEXEC as _).map_err(DrmError::CreateLease)?;
|
||||||
|
log::info!("Created lease {}/{}", self.fd.raw(), lessee_id);
|
||||||
|
Ok(DrmLease {
|
||||||
|
drm_fd: self.fd.clone(),
|
||||||
|
lessee_id,
|
||||||
|
lessee_fd: Rc::new(fd),
|
||||||
|
revoked: Cell::new(false),
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum DrmEvent {
|
pub enum DrmEvent {
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,10 @@ pub unsafe fn ioctl<T>(fd: c::c_int, request: c::c_ulong, t: &mut T) -> Result<c
|
||||||
|
|
||||||
pub const DRM_IOCTL_BASE: u64 = b'd' as u64;
|
pub const DRM_IOCTL_BASE: u64 = b'd' as u64;
|
||||||
|
|
||||||
|
pub const fn drm_io(nr: u64) -> u64 {
|
||||||
|
uapi::_IO(DRM_IOCTL_BASE, nr)
|
||||||
|
}
|
||||||
|
|
||||||
pub const fn drm_iow<T>(nr: u64) -> u64 {
|
pub const fn drm_iow<T>(nr: u64) -> u64 {
|
||||||
uapi::_IOW::<T>(DRM_IOCTL_BASE, nr)
|
uapi::_IOW::<T>(DRM_IOCTL_BASE, nr)
|
||||||
}
|
}
|
||||||
|
|
@ -70,6 +74,21 @@ pub fn create_lease(fd: c::c_int, objects: &[u32], flags: u32) -> Result<(OwnedF
|
||||||
Ok((OwnedFd::new(create.fd as _), create.lessee_id))
|
Ok((OwnedFd::new(create.fd as _), create.lessee_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DRM_IOCTL_MODE_REVOKE_LEASE: u64 = drm_iowr::<drm_mode_revoke_lease>(0xc9);
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
|
struct drm_mode_revoke_lease {
|
||||||
|
lessee_id: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn revoke_lease(fd: c::c_int, lessee_id: u32) -> Result<(), OsError> {
|
||||||
|
let mut revoke = drm_mode_revoke_lease { lessee_id };
|
||||||
|
unsafe {
|
||||||
|
ioctl(fd, DRM_IOCTL_MODE_REVOKE_LEASE, &mut revoke)?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_node_type_from_fd(fd: c::c_int) -> Result<NodeType, OsError> {
|
pub fn get_node_type_from_fd(fd: c::c_int) -> Result<NodeType, OsError> {
|
||||||
let (_, _, min) = drm_stat(fd)?;
|
let (_, _, min) = drm_stat(fd)?;
|
||||||
get_minor_type(min)
|
get_minor_type(min)
|
||||||
|
|
@ -1354,3 +1373,28 @@ pub fn sync_ioc_merge(left: c::c_int, right: c::c_int) -> Result<OwnedFd, OsErro
|
||||||
}
|
}
|
||||||
Ok(OwnedFd::new(res.fence))
|
Ok(OwnedFd::new(res.fence))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const DRM_IOCTL_DROP_MASTER: u64 = drm_io(0x1f);
|
||||||
|
|
||||||
|
pub fn drop_master(fd: c::c_int) -> Result<(), OsError> {
|
||||||
|
let mut res = 0u8;
|
||||||
|
unsafe {
|
||||||
|
ioctl(fd, DRM_IOCTL_DROP_MASTER, &mut res)?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
const DRM_IOCTL_AUTH_MAGIC: u64 = drm_iow::<drm_auth>(0x11);
|
||||||
|
|
||||||
|
#[repr(C)]
|
||||||
|
struct drm_auth {
|
||||||
|
magic: c::c_uint,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn auth_magic(fd: c::c_int, magic: c::c_uint) -> Result<(), OsError> {
|
||||||
|
let mut res = drm_auth { magic };
|
||||||
|
unsafe {
|
||||||
|
ioctl(fd, DRM_IOCTL_AUTH_MAGIC, &mut res)?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,11 @@ request set_enabled {
|
||||||
enabled: u32,
|
enabled: u32,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
request set_non_desktop {
|
||||||
|
output: str,
|
||||||
|
non_desktop: u32,
|
||||||
|
}
|
||||||
|
|
||||||
# events
|
# events
|
||||||
|
|
||||||
event global {
|
event global {
|
||||||
|
|
@ -99,3 +104,11 @@ event mode {
|
||||||
event error {
|
event error {
|
||||||
msg: str,
|
msg: str,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event non_desktop_output {
|
||||||
|
manufacturer: str,
|
||||||
|
product: str,
|
||||||
|
serial_number: str,
|
||||||
|
width_mm: i32,
|
||||||
|
height_mm: i32,
|
||||||
|
}
|
||||||
|
|
|
||||||
23
wire/wp_drm_lease_connector_v1.txt
Normal file
23
wire/wp_drm_lease_connector_v1.txt
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
request destroy {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
event name {
|
||||||
|
name: str,
|
||||||
|
}
|
||||||
|
|
||||||
|
event description {
|
||||||
|
description: str,
|
||||||
|
}
|
||||||
|
|
||||||
|
event connector_id {
|
||||||
|
connector_id: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
event done {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
event withdrawn {
|
||||||
|
|
||||||
|
}
|
||||||
23
wire/wp_drm_lease_device_v1.txt
Normal file
23
wire/wp_drm_lease_device_v1.txt
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
request create_lease_request {
|
||||||
|
id: id(wp_drm_lease_request_v1),
|
||||||
|
}
|
||||||
|
|
||||||
|
request release {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
event drm_fd {
|
||||||
|
fd: fd,
|
||||||
|
}
|
||||||
|
|
||||||
|
event connector {
|
||||||
|
id: id(wp_drm_lease_connector_v1),
|
||||||
|
}
|
||||||
|
|
||||||
|
event done {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
event released {
|
||||||
|
|
||||||
|
}
|
||||||
7
wire/wp_drm_lease_request_v1.txt
Normal file
7
wire/wp_drm_lease_request_v1.txt
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
request request_connector {
|
||||||
|
connector: id(wp_drm_lease_connector_v1),
|
||||||
|
}
|
||||||
|
|
||||||
|
request submit {
|
||||||
|
id: id(wp_drm_lease_v1),
|
||||||
|
}
|
||||||
11
wire/wp_drm_lease_v1.txt
Normal file
11
wire/wp_drm_lease_v1.txt
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
request destroy {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
event lease_fd {
|
||||||
|
leased_fd: fd,
|
||||||
|
}
|
||||||
|
|
||||||
|
event finished {
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue