Skip to content

Commit

Permalink
wayland: implement wp-drm-lease-v1
Browse files Browse the repository at this point in the history
  • Loading branch information
mahkoh committed Apr 26, 2024
1 parent e92c92b commit abbc847
Show file tree
Hide file tree
Showing 27 changed files with 797 additions and 19 deletions.
2 changes: 2 additions & 0 deletions deploy-notes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Unreleased

- Needs jay-compositor release.

# 1.1.0

- Needs jay-config release.
Expand Down
5 changes: 5 additions & 0 deletions docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

## VR

Jay's supports leasing VR headsets to applications.

## Protocol Support

Jay supports the following wayland protocols:
Expand All @@ -139,6 +143,7 @@ Jay supports the following wayland protocols:
| wp_alpha_modifier_v1 | 1 | |
| wp_content_type_manager_v1 | 1 | |
| wp_cursor_shape_manager_v1 | 1 | |
| wp_drm_lease_device_v1 | 1 | |
| wp_fractional_scale_manager_v1 | 1 | |
| wp_linux_drm_syncobj_manager_v1 | 1 | |
| wp_presentation | 1 | |
Expand Down
1 change: 1 addition & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
- Add support for wp-security-manager-v1.
- Add support for xdg-dialog-v1.
- Add support for ext-transient-seat-v1.
- Add support for wp-drm-lease-v1.

# 1.1.0 (2024-04-22)

Expand Down
4 changes: 2 additions & 2 deletions src/acceptor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use {
crate::{
async_engine::SpawnedFuture,
client::{ClientCaps, CAP_LAYER_SHELL},
client::{ClientCaps, CAPS_DEFAULT},
state::State,
utils::{errorfmt::ErrorFmt, oserror::OsError, xrd::xrd},
},
Expand Down Expand Up @@ -154,7 +154,7 @@ impl Acceptor {
state.eng.spawn(accept(
acc.socket.insecure.clone(),
state.clone(),
CAP_LAYER_SHELL,
CAPS_DEFAULT,
)),
];
state.acceptor.set(Some(acc.clone()));
Expand Down
5 changes: 4 additions & 1 deletion src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use {
gfx_api::{GfxFramebuffer, SyncFile},
ifs::wl_seat::wl_pointer::{CONTINUOUS, FINGER, HORIZONTAL_SCROLL, VERTICAL_SCROLL, WHEEL},
libinput::consts::DeviceCapability,
video::drm::{ConnectorType, DrmError, DrmVersion},
video::drm::{ConnectorType, DrmConnector, DrmError, DrmVersion},
},
jay_config::video::GfxApi,
std::{
Expand Down Expand Up @@ -94,6 +94,9 @@ pub trait Connector {
fn set_non_desktop_override(&self, non_desktop: Option<bool>) {
let _ = non_desktop;
}
fn drm_object_id(&self) -> Option<DrmConnector> {
None
}
}

#[derive(Debug)]
Expand Down
4 changes: 4 additions & 0 deletions src/backends/metal/video.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,10 @@ impl Connector for MetalConnector {
}
}
}

fn drm_object_id(&self) -> Option<DrmConnector> {
Some(self.id)
}
}

pub struct MetalCrtc {
Expand Down
4 changes: 4 additions & 0 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,12 @@ bitflags! {
CAP_LAYER_SHELL = 1 << 6,
CAP_SCREENCOPY_MANAGER = 1 << 7,
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)]
pub struct ClientId(u64);

Expand Down
9 changes: 7 additions & 2 deletions src/client/objects.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use {
xdg_surface::{xdg_toplevel::XdgToplevel, XdgSurface},
WlSurface,
},
wp_drm_lease_connector_v1::WpDrmLeaseConnectorV1,
wp_linux_drm_syncobj_timeline_v1::WpLinuxDrmSyncobjTimelineV1,
xdg_positioner::XdgPositioner,
xdg_wm_base::XdgWmBase,
Expand All @@ -32,8 +33,9 @@ use {
wire::{
JayOutputId, JayScreencastId, JayToplevelId, JayWorkspaceId, WlBufferId,
WlDataSourceId, WlOutputId, WlPointerId, WlRegionId, WlRegistryId, WlSeatId,
WlSurfaceId, WpLinuxDrmSyncobjTimelineV1Id, XdgPositionerId, XdgSurfaceId,
XdgToplevelId, XdgWmBaseId, ZwlrDataControlSourceV1Id, ZwpPrimarySelectionSourceV1Id,
WlSurfaceId, WpDrmLeaseConnectorV1Id, WpLinuxDrmSyncobjTimelineV1Id, XdgPositionerId,
XdgSurfaceId, XdgToplevelId, XdgWmBaseId, ZwlrDataControlSourceV1Id,
ZwpPrimarySelectionSourceV1Id,
},
},
std::{cell::RefCell, mem, rc::Rc},
Expand Down Expand Up @@ -62,6 +64,7 @@ pub struct Objects {
pub timelines: CopyHashMap<WpLinuxDrmSyncobjTimelineV1Id, Rc<WpLinuxDrmSyncobjTimelineV1>>,
pub zwlr_data_sources: CopyHashMap<ZwlrDataControlSourceV1Id, Rc<ZwlrDataControlSourceV1>>,
pub jay_toplevels: CopyHashMap<JayToplevelId, Rc<JayToplevel>>,
pub drm_lease_outputs: CopyHashMap<WpDrmLeaseConnectorV1Id, Rc<WpDrmLeaseConnectorV1>>,
ids: RefCell<Vec<usize>>,
}

Expand Down Expand Up @@ -92,6 +95,7 @@ impl Objects {
timelines: Default::default(),
zwlr_data_sources: Default::default(),
jay_toplevels: Default::default(),
drm_lease_outputs: Default::default(),
ids: RefCell::new(vec![]),
}
}
Expand Down Expand Up @@ -126,6 +130,7 @@ impl Objects {
self.timelines.clear();
self.zwlr_data_sources.clear();
self.jay_toplevels.clear();
self.drm_lease_outputs.clear();
}

pub fn id<T>(&self, client_data: &Client) -> Result<T, ClientError>
Expand Down
4 changes: 4 additions & 0 deletions src/ifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ pub mod wp_content_type_manager_v1;
pub mod wp_content_type_v1;
pub mod wp_cursor_shape_device_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_linux_drm_syncobj_manager_v1;
pub mod wp_linux_drm_syncobj_timeline_v1;
Expand Down
93 changes: 93 additions & 0 deletions src/ifs/wp_drm_lease_connector_v1.rs
Original file line number Diff line number Diff line change
@@ -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);
Loading

0 comments on commit abbc847

Please sign in to comment.