Replace screencopy with ext-image-copy-capture-v1
This commit is contained in:
parent
fec4b3c235
commit
2fe5897db0
10 changed files with 545 additions and 575 deletions
|
|
@ -17,7 +17,7 @@ use crate::{
|
||||||
a11y::A11yState,
|
a11y::A11yState,
|
||||||
atspi::AtspiState,
|
atspi::AtspiState,
|
||||||
drm::WlDrmState,
|
drm::WlDrmState,
|
||||||
image_source::ImageSourceState,
|
image_capture_source::ImageCaptureSourceState,
|
||||||
output_configuration::OutputConfigurationState,
|
output_configuration::OutputConfigurationState,
|
||||||
output_power::OutputPowerState,
|
output_power::OutputPowerState,
|
||||||
overlap_notify::OverlapNotifyState,
|
overlap_notify::OverlapNotifyState,
|
||||||
|
|
@ -219,7 +219,7 @@ pub struct Common {
|
||||||
pub presentation_state: PresentationState,
|
pub presentation_state: PresentationState,
|
||||||
pub primary_selection_state: PrimarySelectionState,
|
pub primary_selection_state: PrimarySelectionState,
|
||||||
pub data_control_state: Option<DataControlState>,
|
pub data_control_state: Option<DataControlState>,
|
||||||
pub image_source_state: ImageSourceState,
|
pub image_capture_source_state: ImageCaptureSourceState,
|
||||||
pub screencopy_state: ScreencopyState,
|
pub screencopy_state: ScreencopyState,
|
||||||
pub seat_state: SeatState<State>,
|
pub seat_state: SeatState<State>,
|
||||||
pub session_lock_manager_state: SessionLockManagerState,
|
pub session_lock_manager_state: SessionLockManagerState,
|
||||||
|
|
@ -532,7 +532,8 @@ impl State {
|
||||||
OverlapNotifyState::new::<Self, _>(dh, client_has_no_security_context);
|
OverlapNotifyState::new::<Self, _>(dh, client_has_no_security_context);
|
||||||
let presentation_state = PresentationState::new::<Self>(dh, clock.id() as u32);
|
let presentation_state = PresentationState::new::<Self>(dh, clock.id() as u32);
|
||||||
let primary_selection_state = PrimarySelectionState::new::<Self>(dh);
|
let primary_selection_state = PrimarySelectionState::new::<Self>(dh);
|
||||||
let image_source_state = ImageSourceState::new::<Self, _>(dh, client_is_privileged);
|
let image_capture_source_state =
|
||||||
|
ImageCaptureSourceState::new::<Self, _>(dh, client_is_privileged);
|
||||||
let screencopy_state = ScreencopyState::new::<Self, _>(dh, client_is_privileged);
|
let screencopy_state = ScreencopyState::new::<Self, _>(dh, client_is_privileged);
|
||||||
let shm_state =
|
let shm_state =
|
||||||
ShmState::new::<Self>(dh, vec![wl_shm::Format::Xbgr8888, wl_shm::Format::Abgr8888]);
|
ShmState::new::<Self>(dh, vec![wl_shm::Format::Xbgr8888, wl_shm::Format::Abgr8888]);
|
||||||
|
|
@ -632,7 +633,7 @@ impl State {
|
||||||
idle_notifier_state,
|
idle_notifier_state,
|
||||||
idle_inhibit_manager_state,
|
idle_inhibit_manager_state,
|
||||||
idle_inhibiting_surfaces,
|
idle_inhibiting_surfaces,
|
||||||
image_source_state,
|
image_capture_source_state,
|
||||||
screencopy_state,
|
screencopy_state,
|
||||||
shm_state,
|
shm_state,
|
||||||
cursor_shape_manager_state,
|
cursor_shape_manager_state,
|
||||||
|
|
|
||||||
4
src/wayland/handlers/image_capture_source.rs
Normal file
4
src/wayland/handlers/image_capture_source.rs
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
use crate::state::State;
|
||||||
|
use crate::wayland::protocols::image_capture_source::delegate_image_capture_source;
|
||||||
|
|
||||||
|
delegate_image_capture_source!(State);
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
use crate::state::State;
|
|
||||||
use crate::wayland::protocols::image_source::delegate_image_source;
|
|
||||||
|
|
||||||
delegate_image_source!(State);
|
|
||||||
|
|
@ -16,7 +16,7 @@ pub mod foreign_toplevel_list;
|
||||||
pub mod fractional_scale;
|
pub mod fractional_scale;
|
||||||
pub mod idle_inhibit;
|
pub mod idle_inhibit;
|
||||||
pub mod idle_notify;
|
pub mod idle_notify;
|
||||||
pub mod image_source;
|
pub mod image_capture_source;
|
||||||
pub mod input_method;
|
pub mod input_method;
|
||||||
pub mod keyboard_shortcuts_inhibit;
|
pub mod keyboard_shortcuts_inhibit;
|
||||||
pub mod layer_shell;
|
pub mod layer_shell;
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ use crate::{
|
||||||
OutputExt, PointExt, PointGlobalExt, PointLocalExt, RectExt, RectLocalExt, SeatExt,
|
OutputExt, PointExt, PointGlobalExt, PointLocalExt, RectExt, RectLocalExt, SeatExt,
|
||||||
},
|
},
|
||||||
wayland::protocols::{
|
wayland::protocols::{
|
||||||
image_source::ImageSourceData,
|
image_capture_source::ImageCaptureSourceData,
|
||||||
screencopy::{
|
screencopy::{
|
||||||
delegate_screencopy, BufferConstraints, CursorSession, DmabufConstraints, Frame,
|
delegate_screencopy, BufferConstraints, CursorSession, DmabufConstraints, Frame,
|
||||||
ScreencopyHandler, ScreencopyState, Session,
|
ScreencopyHandler, ScreencopyState, Session,
|
||||||
|
|
@ -44,23 +44,26 @@ impl ScreencopyHandler for State {
|
||||||
&mut self.common.screencopy_state
|
&mut self.common.screencopy_state
|
||||||
}
|
}
|
||||||
|
|
||||||
fn capture_source(&mut self, source: &ImageSourceData) -> Option<BufferConstraints> {
|
fn capture_source(&mut self, source: &ImageCaptureSourceData) -> Option<BufferConstraints> {
|
||||||
match source {
|
match source {
|
||||||
ImageSourceData::Output(weak) => weak
|
ImageCaptureSourceData::Output(weak) => weak
|
||||||
.upgrade()
|
.upgrade()
|
||||||
.and_then(|output| constraints_for_output(&output, &mut self.backend)),
|
.and_then(|output| constraints_for_output(&output, &mut self.backend)),
|
||||||
ImageSourceData::Workspace(handle) => {
|
ImageCaptureSourceData::Workspace(handle) => {
|
||||||
let shell = self.common.shell.read().unwrap();
|
let shell = self.common.shell.read().unwrap();
|
||||||
let output = shell.workspaces.space_for_handle(&handle)?.output();
|
let output = shell.workspaces.space_for_handle(&handle)?.output();
|
||||||
constraints_for_output(output, &mut self.backend)
|
constraints_for_output(output, &mut self.backend)
|
||||||
}
|
}
|
||||||
ImageSourceData::Toplevel(window) => {
|
ImageCaptureSourceData::Toplevel(window) => {
|
||||||
constraints_for_toplevel(window, &mut self.backend)
|
constraints_for_toplevel(window, &mut self.backend)
|
||||||
}
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn capture_cursor_source(&mut self, _source: &ImageSourceData) -> Option<BufferConstraints> {
|
fn capture_cursor_source(
|
||||||
|
&mut self,
|
||||||
|
_source: &ImageCaptureSourceData,
|
||||||
|
) -> Option<BufferConstraints> {
|
||||||
let size = if let Some((geometry, _)) = self
|
let size = if let Some((geometry, _)) = self
|
||||||
.common
|
.common
|
||||||
.shell
|
.shell
|
||||||
|
|
@ -84,7 +87,7 @@ impl ScreencopyHandler for State {
|
||||||
|
|
||||||
fn new_session(&mut self, session: Session) {
|
fn new_session(&mut self, session: Session) {
|
||||||
match session.source() {
|
match session.source() {
|
||||||
ImageSourceData::Output(weak) => {
|
ImageCaptureSourceData::Output(weak) => {
|
||||||
let Some(mut output) = weak.upgrade() else {
|
let Some(mut output) = weak.upgrade() else {
|
||||||
session.stop();
|
session.stop();
|
||||||
return;
|
return;
|
||||||
|
|
@ -98,7 +101,7 @@ impl ScreencopyHandler for State {
|
||||||
|
|
||||||
output.add_session(session);
|
output.add_session(session);
|
||||||
}
|
}
|
||||||
ImageSourceData::Workspace(handle) => {
|
ImageCaptureSourceData::Workspace(handle) => {
|
||||||
let mut shell = self.common.shell.write().unwrap();
|
let mut shell = self.common.shell.write().unwrap();
|
||||||
let Some(workspace) = shell.workspaces.space_for_handle_mut(&handle) else {
|
let Some(workspace) = shell.workspaces.space_for_handle_mut(&handle) else {
|
||||||
session.stop();
|
session.stop();
|
||||||
|
|
@ -112,7 +115,7 @@ impl ScreencopyHandler for State {
|
||||||
});
|
});
|
||||||
workspace.add_session(session);
|
workspace.add_session(session);
|
||||||
}
|
}
|
||||||
ImageSourceData::Toplevel(mut toplevel) => {
|
ImageCaptureSourceData::Toplevel(mut toplevel) => {
|
||||||
let size = toplevel.geometry().size.to_physical(1);
|
let size = toplevel.geometry().size.to_physical(1);
|
||||||
session.user_data().insert_if_missing_threadsafe(|| {
|
session.user_data().insert_if_missing_threadsafe(|| {
|
||||||
Mutex::new(SessionUserData::new(OutputDamageTracker::new(
|
Mutex::new(SessionUserData::new(OutputDamageTracker::new(
|
||||||
|
|
@ -123,7 +126,7 @@ impl ScreencopyHandler for State {
|
||||||
});
|
});
|
||||||
toplevel.add_session(session);
|
toplevel.add_session(session);
|
||||||
}
|
}
|
||||||
ImageSourceData::Destroyed => unreachable!(),
|
ImageCaptureSourceData::Destroyed => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn new_cursor_session(&mut self, session: CursorSession) {
|
fn new_cursor_session(&mut self, session: CursorSession) {
|
||||||
|
|
@ -160,7 +163,7 @@ impl ScreencopyHandler for State {
|
||||||
});
|
});
|
||||||
|
|
||||||
match session.source() {
|
match session.source() {
|
||||||
ImageSourceData::Output(weak) => {
|
ImageCaptureSourceData::Output(weak) => {
|
||||||
let Some(mut output) = weak.upgrade() else {
|
let Some(mut output) = weak.upgrade() else {
|
||||||
session.stop();
|
session.stop();
|
||||||
return;
|
return;
|
||||||
|
|
@ -190,7 +193,7 @@ impl ScreencopyHandler for State {
|
||||||
|
|
||||||
output.add_cursor_session(session);
|
output.add_cursor_session(session);
|
||||||
}
|
}
|
||||||
ImageSourceData::Workspace(handle) => {
|
ImageCaptureSourceData::Workspace(handle) => {
|
||||||
let mut shell = self.common.shell.write().unwrap();
|
let mut shell = self.common.shell.write().unwrap();
|
||||||
let Some(workspace) = shell.workspaces.space_for_handle_mut(&handle) else {
|
let Some(workspace) = shell.workspaces.space_for_handle_mut(&handle) else {
|
||||||
session.stop();
|
session.stop();
|
||||||
|
|
@ -222,7 +225,7 @@ impl ScreencopyHandler for State {
|
||||||
|
|
||||||
workspace.add_cursor_session(session);
|
workspace.add_cursor_session(session);
|
||||||
}
|
}
|
||||||
ImageSourceData::Toplevel(mut toplevel) => {
|
ImageCaptureSourceData::Toplevel(mut toplevel) => {
|
||||||
let shell = self.common.shell.read().unwrap();
|
let shell = self.common.shell.read().unwrap();
|
||||||
if let Some(element) = shell.element_for_surface(&toplevel) {
|
if let Some(element) = shell.element_for_surface(&toplevel) {
|
||||||
if element.has_active_window(&toplevel) {
|
if element.has_active_window(&toplevel) {
|
||||||
|
|
@ -245,13 +248,13 @@ impl ScreencopyHandler for State {
|
||||||
|
|
||||||
toplevel.add_cursor_session(session);
|
toplevel.add_cursor_session(session);
|
||||||
}
|
}
|
||||||
ImageSourceData::Destroyed => unreachable!(),
|
ImageCaptureSourceData::Destroyed => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn frame(&mut self, session: Session, frame: Frame) {
|
fn frame(&mut self, session: Session, frame: Frame) {
|
||||||
match session.source() {
|
match session.source() {
|
||||||
ImageSourceData::Output(weak) => {
|
ImageCaptureSourceData::Output(weak) => {
|
||||||
let Some(mut output) = weak.upgrade() else {
|
let Some(mut output) = weak.upgrade() else {
|
||||||
session.stop(); // will fail the frame as well
|
session.stop(); // will fail the frame as well
|
||||||
return;
|
return;
|
||||||
|
|
@ -260,13 +263,13 @@ impl ScreencopyHandler for State {
|
||||||
output.add_frame(session, frame);
|
output.add_frame(session, frame);
|
||||||
self.backend.schedule_render(&output);
|
self.backend.schedule_render(&output);
|
||||||
}
|
}
|
||||||
ImageSourceData::Workspace(handle) => {
|
ImageCaptureSourceData::Workspace(handle) => {
|
||||||
render_workspace_to_buffer(self, session, frame, handle)
|
render_workspace_to_buffer(self, session, frame, handle)
|
||||||
}
|
}
|
||||||
ImageSourceData::Toplevel(toplevel) => {
|
ImageCaptureSourceData::Toplevel(toplevel) => {
|
||||||
render_window_to_buffer(self, session, frame, &toplevel)
|
render_window_to_buffer(self, session, frame, &toplevel)
|
||||||
}
|
}
|
||||||
ImageSourceData::Destroyed => unreachable!(),
|
ImageCaptureSourceData::Destroyed => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -296,12 +299,12 @@ impl ScreencopyHandler for State {
|
||||||
|
|
||||||
fn session_destroyed(&mut self, session: Session) {
|
fn session_destroyed(&mut self, session: Session) {
|
||||||
match session.source() {
|
match session.source() {
|
||||||
ImageSourceData::Output(weak) => {
|
ImageCaptureSourceData::Output(weak) => {
|
||||||
if let Some(mut output) = weak.upgrade() {
|
if let Some(mut output) = weak.upgrade() {
|
||||||
output.remove_session(session);
|
output.remove_session(session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImageSourceData::Workspace(handle) => {
|
ImageCaptureSourceData::Workspace(handle) => {
|
||||||
if let Some(workspace) = self
|
if let Some(workspace) = self
|
||||||
.common
|
.common
|
||||||
.shell
|
.shell
|
||||||
|
|
@ -313,19 +316,19 @@ impl ScreencopyHandler for State {
|
||||||
workspace.remove_session(session)
|
workspace.remove_session(session)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImageSourceData::Toplevel(mut toplevel) => toplevel.remove_session(session),
|
ImageCaptureSourceData::Toplevel(mut toplevel) => toplevel.remove_session(session),
|
||||||
ImageSourceData::Destroyed => unreachable!(),
|
ImageCaptureSourceData::Destroyed => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cursor_session_destroyed(&mut self, session: CursorSession) {
|
fn cursor_session_destroyed(&mut self, session: CursorSession) {
|
||||||
match session.source() {
|
match session.source() {
|
||||||
ImageSourceData::Output(weak) => {
|
ImageCaptureSourceData::Output(weak) => {
|
||||||
if let Some(mut output) = weak.upgrade() {
|
if let Some(mut output) = weak.upgrade() {
|
||||||
output.remove_cursor_session(session);
|
output.remove_cursor_session(session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImageSourceData::Workspace(handle) => {
|
ImageCaptureSourceData::Workspace(handle) => {
|
||||||
if let Some(workspace) = self
|
if let Some(workspace) = self
|
||||||
.common
|
.common
|
||||||
.shell
|
.shell
|
||||||
|
|
@ -337,8 +340,10 @@ impl ScreencopyHandler for State {
|
||||||
workspace.remove_cursor_session(session)
|
workspace.remove_cursor_session(session)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImageSourceData::Toplevel(mut toplevel) => toplevel.remove_cursor_session(session),
|
ImageCaptureSourceData::Toplevel(mut toplevel) => {
|
||||||
ImageSourceData::Destroyed => unreachable!(),
|
toplevel.remove_cursor_session(session)
|
||||||
|
}
|
||||||
|
ImageCaptureSourceData::Destroyed => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
372
src/wayland/protocols/image_capture_source.rs
Normal file
372
src/wayland/protocols/image_capture_source.rs
Normal file
|
|
@ -0,0 +1,372 @@
|
||||||
|
use super::{
|
||||||
|
toplevel_info::window_from_ext_handle,
|
||||||
|
workspace::{WorkspaceHandle, WorkspaceHandler},
|
||||||
|
};
|
||||||
|
use crate::{
|
||||||
|
shell::CosmicSurface,
|
||||||
|
wayland::protocols::toplevel_info::ToplevelInfoHandler,
|
||||||
|
};
|
||||||
|
use cosmic_protocols::image_capture_source::v1::server::{
|
||||||
|
zcosmic_workspace_image_capture_source_manager_v1::{
|
||||||
|
Request as CosmicWorkspaceSourceRequest, ZcosmicWorkspaceImageCaptureSourceManagerV1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
use smithay::reexports::wayland_protocols::ext::image_capture_source::v1::server::{
|
||||||
|
ext_foreign_toplevel_image_capture_source_manager_v1::{
|
||||||
|
Request as ToplevelSourceRequest, ExtForeignToplevelImageCaptureSourceManagerV1,
|
||||||
|
},
|
||||||
|
ext_image_capture_source_v1::ExtImageCaptureSourceV1,
|
||||||
|
ext_output_image_capture_source_manager_v1::{
|
||||||
|
Request as OutputSourceRequest, ExtOutputImageCaptureSourceManagerV1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
use smithay::{
|
||||||
|
output::{Output, WeakOutput},
|
||||||
|
reexports::wayland_server::{
|
||||||
|
Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
use wayland_backend::server::GlobalId;
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct ImageCaptureSourceState {
|
||||||
|
output_source_global: GlobalId,
|
||||||
|
workspace_source_global: GlobalId,
|
||||||
|
toplevel_source_global: GlobalId,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct OutputImageCaptureSourceManagerGlobalData {
|
||||||
|
filter: Box<dyn for<'a> Fn(&'a Client) -> bool + Send + Sync>,
|
||||||
|
}
|
||||||
|
pub struct WorkspaceImageCaptureSourceManagerGlobalData {
|
||||||
|
filter: Box<dyn for<'a> Fn(&'a Client) -> bool + Send + Sync>,
|
||||||
|
}
|
||||||
|
pub struct ToplevelImageCaptureSourceManagerGlobalData {
|
||||||
|
filter: Box<dyn for<'a> Fn(&'a Client) -> bool + Send + Sync>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, PartialEq)]
|
||||||
|
pub enum ImageCaptureSourceData {
|
||||||
|
Output(WeakOutput),
|
||||||
|
Workspace(WorkspaceHandle),
|
||||||
|
Toplevel(CosmicSurface),
|
||||||
|
Destroyed,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ImageCaptureSourceState {
|
||||||
|
pub fn new<D, F>(display: &DisplayHandle, client_filter: F) -> ImageCaptureSourceState
|
||||||
|
where
|
||||||
|
D: GlobalDispatch<
|
||||||
|
ExtOutputImageCaptureSourceManagerV1,
|
||||||
|
OutputImageCaptureSourceManagerGlobalData,
|
||||||
|
> + Dispatch<ExtOutputImageCaptureSourceManagerV1, ()>
|
||||||
|
+ GlobalDispatch<
|
||||||
|
ZcosmicWorkspaceImageCaptureSourceManagerV1,
|
||||||
|
WorkspaceImageCaptureSourceManagerGlobalData,
|
||||||
|
> + Dispatch<ZcosmicWorkspaceImageCaptureSourceManagerV1, ()>
|
||||||
|
+ GlobalDispatch<
|
||||||
|
ExtForeignToplevelImageCaptureSourceManagerV1,
|
||||||
|
ToplevelImageCaptureSourceManagerGlobalData,
|
||||||
|
> + Dispatch<ExtForeignToplevelImageCaptureSourceManagerV1, ()>
|
||||||
|
+ Dispatch<ExtImageCaptureSourceV1, ImageCaptureSourceData>
|
||||||
|
+ WorkspaceHandler
|
||||||
|
+ 'static,
|
||||||
|
F: for<'a> Fn(&'a Client) -> bool + Send + Sync + Clone + 'static,
|
||||||
|
{
|
||||||
|
ImageCaptureSourceState {
|
||||||
|
output_source_global: display
|
||||||
|
.create_global::<D, ExtOutputImageCaptureSourceManagerV1, _>(
|
||||||
|
1,
|
||||||
|
OutputImageCaptureSourceManagerGlobalData {
|
||||||
|
filter: Box::new(client_filter.clone()),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
workspace_source_global: display
|
||||||
|
.create_global::<D, ZcosmicWorkspaceImageCaptureSourceManagerV1, _>(
|
||||||
|
1,
|
||||||
|
WorkspaceImageCaptureSourceManagerGlobalData {
|
||||||
|
filter: Box::new(client_filter.clone()),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
toplevel_source_global: display
|
||||||
|
.create_global::<D, ExtForeignToplevelImageCaptureSourceManagerV1, _>(
|
||||||
|
1,
|
||||||
|
ToplevelImageCaptureSourceManagerGlobalData {
|
||||||
|
filter: Box::new(client_filter),
|
||||||
|
},
|
||||||
|
),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn output_source_id(&self) -> &GlobalId {
|
||||||
|
&self.output_source_global
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn workspace_source_id(&self) -> &GlobalId {
|
||||||
|
&self.workspace_source_global
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn toplevel_source_id(&self) -> &GlobalId {
|
||||||
|
&self.toplevel_source_global
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<D>
|
||||||
|
GlobalDispatch<
|
||||||
|
ExtOutputImageCaptureSourceManagerV1,
|
||||||
|
OutputImageCaptureSourceManagerGlobalData,
|
||||||
|
D,
|
||||||
|
> for ImageCaptureSourceState
|
||||||
|
where
|
||||||
|
D: GlobalDispatch<
|
||||||
|
ExtOutputImageCaptureSourceManagerV1,
|
||||||
|
OutputImageCaptureSourceManagerGlobalData,
|
||||||
|
> + Dispatch<ExtOutputImageCaptureSourceManagerV1, ()>
|
||||||
|
+ Dispatch<ExtImageCaptureSourceV1, ImageCaptureSourceData>
|
||||||
|
+ 'static,
|
||||||
|
{
|
||||||
|
fn bind(
|
||||||
|
_state: &mut D,
|
||||||
|
_handle: &DisplayHandle,
|
||||||
|
_client: &Client,
|
||||||
|
resource: New<ExtOutputImageCaptureSourceManagerV1>,
|
||||||
|
_global_data: &OutputImageCaptureSourceManagerGlobalData,
|
||||||
|
data_init: &mut DataInit<'_, D>,
|
||||||
|
) {
|
||||||
|
data_init.init(resource, ());
|
||||||
|
}
|
||||||
|
|
||||||
|
fn can_view(client: Client, global_data: &OutputImageCaptureSourceManagerGlobalData) -> bool {
|
||||||
|
(global_data.filter)(&client)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<D>
|
||||||
|
GlobalDispatch<
|
||||||
|
ZcosmicWorkspaceImageCaptureSourceManagerV1,
|
||||||
|
WorkspaceImageCaptureSourceManagerGlobalData,
|
||||||
|
D,
|
||||||
|
> for ImageCaptureSourceState
|
||||||
|
where
|
||||||
|
D: GlobalDispatch<
|
||||||
|
ZcosmicWorkspaceImageCaptureSourceManagerV1,
|
||||||
|
WorkspaceImageCaptureSourceManagerGlobalData,
|
||||||
|
> + Dispatch<ZcosmicWorkspaceImageCaptureSourceManagerV1, ()>
|
||||||
|
+ Dispatch<ExtImageCaptureSourceV1, ImageCaptureSourceData>
|
||||||
|
+ 'static,
|
||||||
|
{
|
||||||
|
fn bind(
|
||||||
|
_state: &mut D,
|
||||||
|
_handle: &DisplayHandle,
|
||||||
|
_client: &Client,
|
||||||
|
resource: New<ZcosmicWorkspaceImageCaptureSourceManagerV1>,
|
||||||
|
_global_data: &WorkspaceImageCaptureSourceManagerGlobalData,
|
||||||
|
data_init: &mut DataInit<'_, D>,
|
||||||
|
) {
|
||||||
|
data_init.init(resource, ());
|
||||||
|
}
|
||||||
|
|
||||||
|
fn can_view(
|
||||||
|
client: Client,
|
||||||
|
global_data: &WorkspaceImageCaptureSourceManagerGlobalData,
|
||||||
|
) -> bool {
|
||||||
|
(global_data.filter)(&client)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<D>
|
||||||
|
GlobalDispatch<
|
||||||
|
ExtForeignToplevelImageCaptureSourceManagerV1,
|
||||||
|
ToplevelImageCaptureSourceManagerGlobalData,
|
||||||
|
D,
|
||||||
|
> for ImageCaptureSourceState
|
||||||
|
where
|
||||||
|
D: GlobalDispatch<
|
||||||
|
ExtForeignToplevelImageCaptureSourceManagerV1,
|
||||||
|
ToplevelImageCaptureSourceManagerGlobalData,
|
||||||
|
> + Dispatch<ExtForeignToplevelImageCaptureSourceManagerV1, ()>
|
||||||
|
+ Dispatch<ExtImageCaptureSourceV1, ImageCaptureSourceData>
|
||||||
|
+ 'static,
|
||||||
|
{
|
||||||
|
fn bind(
|
||||||
|
_state: &mut D,
|
||||||
|
_handle: &DisplayHandle,
|
||||||
|
_client: &Client,
|
||||||
|
resource: New<ExtForeignToplevelImageCaptureSourceManagerV1>,
|
||||||
|
_global_data: &ToplevelImageCaptureSourceManagerGlobalData,
|
||||||
|
data_init: &mut DataInit<'_, D>,
|
||||||
|
) {
|
||||||
|
data_init.init(resource, ());
|
||||||
|
}
|
||||||
|
|
||||||
|
fn can_view(client: Client, global_data: &ToplevelImageCaptureSourceManagerGlobalData) -> bool {
|
||||||
|
(global_data.filter)(&client)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<D> Dispatch<ExtOutputImageCaptureSourceManagerV1, (), D> for ImageCaptureSourceState
|
||||||
|
where
|
||||||
|
D: Dispatch<ExtOutputImageCaptureSourceManagerV1, ()>
|
||||||
|
+ Dispatch<ExtImageCaptureSourceV1, ImageCaptureSourceData>
|
||||||
|
+ 'static,
|
||||||
|
{
|
||||||
|
fn request(
|
||||||
|
_state: &mut D,
|
||||||
|
_client: &Client,
|
||||||
|
_resource: &ExtOutputImageCaptureSourceManagerV1,
|
||||||
|
request: <ExtOutputImageCaptureSourceManagerV1 as Resource>::Request,
|
||||||
|
_data: &(),
|
||||||
|
_dhandle: &DisplayHandle,
|
||||||
|
data_init: &mut DataInit<'_, D>,
|
||||||
|
) {
|
||||||
|
match request {
|
||||||
|
OutputSourceRequest::CreateSource { source, output } => {
|
||||||
|
let data = match Output::from_resource(&output) {
|
||||||
|
Some(output) => ImageCaptureSourceData::Output(output.downgrade()),
|
||||||
|
None => ImageCaptureSourceData::Destroyed,
|
||||||
|
};
|
||||||
|
data_init.init(source, data);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn destroyed(
|
||||||
|
_state: &mut D,
|
||||||
|
_client: wayland_backend::server::ClientId,
|
||||||
|
_resource: &ExtOutputImageCaptureSourceManagerV1,
|
||||||
|
_data: &(),
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<D> Dispatch<ZcosmicWorkspaceImageCaptureSourceManagerV1, (), D> for ImageCaptureSourceState
|
||||||
|
where
|
||||||
|
D: Dispatch<ZcosmicWorkspaceImageCaptureSourceManagerV1, ()>
|
||||||
|
+ Dispatch<ExtImageCaptureSourceV1, ImageCaptureSourceData>
|
||||||
|
+ WorkspaceHandler
|
||||||
|
+ 'static,
|
||||||
|
{
|
||||||
|
fn request(
|
||||||
|
state: &mut D,
|
||||||
|
_client: &Client,
|
||||||
|
_resource: &ZcosmicWorkspaceImageCaptureSourceManagerV1,
|
||||||
|
request: <ZcosmicWorkspaceImageCaptureSourceManagerV1 as Resource>::Request,
|
||||||
|
_data: &(),
|
||||||
|
_dhandle: &DisplayHandle,
|
||||||
|
data_init: &mut DataInit<'_, D>,
|
||||||
|
) {
|
||||||
|
match request {
|
||||||
|
CosmicWorkspaceSourceRequest::CreateSource { source, output } => {
|
||||||
|
let data = match state.workspace_state().get_ext_workspace_handle(&output) {
|
||||||
|
Some(workspace) => ImageCaptureSourceData::Workspace(workspace),
|
||||||
|
None => ImageCaptureSourceData::Destroyed,
|
||||||
|
};
|
||||||
|
data_init.init(source, data);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn destroyed(
|
||||||
|
_state: &mut D,
|
||||||
|
_client: wayland_backend::server::ClientId,
|
||||||
|
_resource: &ZcosmicWorkspaceImageCaptureSourceManagerV1,
|
||||||
|
_data: &(),
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<D> Dispatch<ExtForeignToplevelImageCaptureSourceManagerV1, (), D> for ImageCaptureSourceState
|
||||||
|
where
|
||||||
|
D: Dispatch<ExtForeignToplevelImageCaptureSourceManagerV1, ()>
|
||||||
|
+ Dispatch<ExtImageCaptureSourceV1, ImageCaptureSourceData>
|
||||||
|
+ ToplevelInfoHandler<Window = CosmicSurface>
|
||||||
|
+ 'static,
|
||||||
|
{
|
||||||
|
fn request(
|
||||||
|
state: &mut D,
|
||||||
|
_client: &Client,
|
||||||
|
_resource: &ExtForeignToplevelImageCaptureSourceManagerV1,
|
||||||
|
request: <ExtForeignToplevelImageCaptureSourceManagerV1 as Resource>::Request,
|
||||||
|
_data: &(),
|
||||||
|
_dhandle: &DisplayHandle,
|
||||||
|
data_init: &mut DataInit<'_, D>,
|
||||||
|
) {
|
||||||
|
match request {
|
||||||
|
ToplevelSourceRequest::CreateSource {
|
||||||
|
source,
|
||||||
|
toplevel_handle,
|
||||||
|
} => {
|
||||||
|
let data = match window_from_ext_handle(state, &toplevel_handle) {
|
||||||
|
Some(toplevel) => ImageCaptureSourceData::Toplevel(toplevel.clone()),
|
||||||
|
None => ImageCaptureSourceData::Destroyed,
|
||||||
|
};
|
||||||
|
data_init.init(source, data);
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn destroyed(
|
||||||
|
_state: &mut D,
|
||||||
|
_client: wayland_backend::server::ClientId,
|
||||||
|
_resource: &ExtForeignToplevelImageCaptureSourceManagerV1,
|
||||||
|
_data: &(),
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<D> Dispatch<ExtImageCaptureSourceV1, ImageCaptureSourceData, D> for ImageCaptureSourceState
|
||||||
|
where
|
||||||
|
D: Dispatch<ExtImageCaptureSourceV1, ImageCaptureSourceData> + 'static,
|
||||||
|
{
|
||||||
|
fn request(
|
||||||
|
_state: &mut D,
|
||||||
|
_client: &Client,
|
||||||
|
_resource: &ExtImageCaptureSourceV1,
|
||||||
|
request: <ExtImageCaptureSourceV1 as Resource>::Request,
|
||||||
|
_data: &ImageCaptureSourceData,
|
||||||
|
_dhandle: &DisplayHandle,
|
||||||
|
_data_init: &mut DataInit<'_, D>,
|
||||||
|
) {
|
||||||
|
match request {
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn destroyed(
|
||||||
|
_state: &mut D,
|
||||||
|
_client: wayland_backend::server::ClientId,
|
||||||
|
_resource: &ExtImageCaptureSourceV1,
|
||||||
|
_data: &ImageCaptureSourceData,
|
||||||
|
) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! delegate_image_capture_source {
|
||||||
|
($(@<$( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+>)? $ty: ty) => {
|
||||||
|
smithay::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
||||||
|
smithay::reexports::wayland_protocols::ext::image_capture_source::v1::server::ext_output_image_capture_source_manager_v1::ExtOutputImageCaptureSourceManagerV1: $crate::wayland::protocols::image_capture_source::OutputImageCaptureSourceManagerGlobalData
|
||||||
|
] => $crate::wayland::protocols::image_capture_source::ImageCaptureSourceState);
|
||||||
|
smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
||||||
|
smithay::reexports::wayland_protocols::ext::image_capture_source::v1::server::ext_output_image_capture_source_manager_v1::ExtOutputImageCaptureSourceManagerV1: ()
|
||||||
|
] => $crate::wayland::protocols::image_capture_source::ImageCaptureSourceState);
|
||||||
|
smithay::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
||||||
|
cosmic_protocols::image_capture_source::v1::server::zcosmic_workspace_image_capture_source_manager_v1::ZcosmicWorkspaceImageCaptureSourceManagerV1: $crate::wayland::protocols::image_capture_source::WorkspaceImageCaptureSourceManagerGlobalData
|
||||||
|
] => $crate::wayland::protocols::image_capture_source::ImageCaptureSourceState);
|
||||||
|
smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
||||||
|
cosmic_protocols::image_capture_source::v1::server::zcosmic_workspace_image_capture_source_manager_v1::ZcosmicWorkspaceImageCaptureSourceManagerV1: ()
|
||||||
|
] => $crate::wayland::protocols::image_capture_source::ImageCaptureSourceState);
|
||||||
|
smithay::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
||||||
|
smithay::reexports::wayland_protocols::ext::image_capture_source::v1::server::ext_foreign_toplevel_image_capture_source_manager_v1::ExtForeignToplevelImageCaptureSourceManagerV1: $crate::wayland::protocols::image_capture_source::ToplevelImageCaptureSourceManagerGlobalData
|
||||||
|
] => $crate::wayland::protocols::image_capture_source::ImageCaptureSourceState);
|
||||||
|
smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
||||||
|
smithay::reexports::wayland_protocols::ext::image_capture_source::v1::server::ext_foreign_toplevel_image_capture_source_manager_v1::ExtForeignToplevelImageCaptureSourceManagerV1: ()
|
||||||
|
] => $crate::wayland::protocols::image_capture_source::ImageCaptureSourceState);
|
||||||
|
smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
||||||
|
smithay::reexports::wayland_protocols::ext::image_capture_source::v1::server::ext_image_capture_source_v1::ExtImageCaptureSourceV1: $crate::wayland::protocols::image_capture_source::ImageCaptureSourceData
|
||||||
|
] => $crate::wayland::protocols::image_capture_source::ImageCaptureSourceState);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
pub(crate) use delegate_image_capture_source;
|
||||||
|
|
@ -1,435 +0,0 @@
|
||||||
use super::{
|
|
||||||
toplevel_info::window_from_handle,
|
|
||||||
workspace::{WorkspaceHandle, WorkspaceHandler},
|
|
||||||
};
|
|
||||||
use crate::shell::CosmicSurface;
|
|
||||||
use cosmic_protocols::image_source::v1::server::{
|
|
||||||
zcosmic_ext_workspace_image_source_manager_v1::{
|
|
||||||
Request as ExtWorkspaceSourceRequest, ZcosmicExtWorkspaceImageSourceManagerV1,
|
|
||||||
},
|
|
||||||
zcosmic_image_source_v1::ZcosmicImageSourceV1,
|
|
||||||
zcosmic_output_image_source_manager_v1::{
|
|
||||||
Request as OutputSourceRequest, ZcosmicOutputImageSourceManagerV1,
|
|
||||||
},
|
|
||||||
zcosmic_toplevel_image_source_manager_v1::{
|
|
||||||
Request as ToplevelSourceRequest, ZcosmicToplevelImageSourceManagerV1,
|
|
||||||
},
|
|
||||||
zcosmic_workspace_image_source_manager_v1::{
|
|
||||||
Request as WorkspaceSourceRequest, ZcosmicWorkspaceImageSourceManagerV1,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
use smithay::{
|
|
||||||
output::{Output, WeakOutput},
|
|
||||||
reexports::wayland_server::{
|
|
||||||
Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
use wayland_backend::server::GlobalId;
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct ImageSourceState {
|
|
||||||
output_source_global: GlobalId,
|
|
||||||
workspace_source_global: GlobalId,
|
|
||||||
ext_workspace_source_global: GlobalId,
|
|
||||||
toplevel_source_global: GlobalId,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct OutputImageSourceManagerGlobalData {
|
|
||||||
filter: Box<dyn for<'a> Fn(&'a Client) -> bool + Send + Sync>,
|
|
||||||
}
|
|
||||||
pub struct WorkspaceImageSourceManagerGlobalData {
|
|
||||||
filter: Box<dyn for<'a> Fn(&'a Client) -> bool + Send + Sync>,
|
|
||||||
}
|
|
||||||
pub struct ToplevelImageSourceManagerGlobalData {
|
|
||||||
filter: Box<dyn for<'a> Fn(&'a Client) -> bool + Send + Sync>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
|
||||||
pub enum ImageSourceData {
|
|
||||||
Output(WeakOutput),
|
|
||||||
Workspace(WorkspaceHandle),
|
|
||||||
Toplevel(CosmicSurface),
|
|
||||||
Destroyed,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ImageSourceState {
|
|
||||||
pub fn new<D, F>(display: &DisplayHandle, client_filter: F) -> ImageSourceState
|
|
||||||
where
|
|
||||||
D: GlobalDispatch<ZcosmicOutputImageSourceManagerV1, OutputImageSourceManagerGlobalData>
|
|
||||||
+ Dispatch<ZcosmicOutputImageSourceManagerV1, ()>
|
|
||||||
+ GlobalDispatch<
|
|
||||||
ZcosmicWorkspaceImageSourceManagerV1,
|
|
||||||
WorkspaceImageSourceManagerGlobalData,
|
|
||||||
> + Dispatch<ZcosmicWorkspaceImageSourceManagerV1, ()>
|
|
||||||
+ GlobalDispatch<
|
|
||||||
ZcosmicExtWorkspaceImageSourceManagerV1,
|
|
||||||
WorkspaceImageSourceManagerGlobalData,
|
|
||||||
> + Dispatch<ZcosmicExtWorkspaceImageSourceManagerV1, ()>
|
|
||||||
+ GlobalDispatch<
|
|
||||||
ZcosmicToplevelImageSourceManagerV1,
|
|
||||||
ToplevelImageSourceManagerGlobalData,
|
|
||||||
> + Dispatch<ZcosmicToplevelImageSourceManagerV1, ()>
|
|
||||||
+ Dispatch<ZcosmicImageSourceV1, ImageSourceData>
|
|
||||||
+ WorkspaceHandler
|
|
||||||
+ 'static,
|
|
||||||
F: for<'a> Fn(&'a Client) -> bool + Send + Sync + Clone + 'static,
|
|
||||||
{
|
|
||||||
ImageSourceState {
|
|
||||||
output_source_global: display.create_global::<D, ZcosmicOutputImageSourceManagerV1, _>(
|
|
||||||
1,
|
|
||||||
OutputImageSourceManagerGlobalData {
|
|
||||||
filter: Box::new(client_filter.clone()),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
workspace_source_global: display
|
|
||||||
.create_global::<D, ZcosmicWorkspaceImageSourceManagerV1, _>(
|
|
||||||
1,
|
|
||||||
WorkspaceImageSourceManagerGlobalData {
|
|
||||||
filter: Box::new(client_filter.clone()),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ext_workspace_source_global: display
|
|
||||||
.create_global::<D, ZcosmicExtWorkspaceImageSourceManagerV1, _>(
|
|
||||||
1,
|
|
||||||
WorkspaceImageSourceManagerGlobalData {
|
|
||||||
filter: Box::new(client_filter.clone()),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
toplevel_source_global: display
|
|
||||||
.create_global::<D, ZcosmicToplevelImageSourceManagerV1, _>(
|
|
||||||
1,
|
|
||||||
ToplevelImageSourceManagerGlobalData {
|
|
||||||
filter: Box::new(client_filter),
|
|
||||||
},
|
|
||||||
),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn output_source_id(&self) -> &GlobalId {
|
|
||||||
&self.output_source_global
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn workspace_source_id(&self) -> &GlobalId {
|
|
||||||
&self.workspace_source_global
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn ext_workspace_source_id(&self) -> &GlobalId {
|
|
||||||
&self.ext_workspace_source_global
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn toplevel_source_id(&self) -> &GlobalId {
|
|
||||||
&self.toplevel_source_global
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<D> GlobalDispatch<ZcosmicOutputImageSourceManagerV1, OutputImageSourceManagerGlobalData, D>
|
|
||||||
for ImageSourceState
|
|
||||||
where
|
|
||||||
D: GlobalDispatch<ZcosmicOutputImageSourceManagerV1, OutputImageSourceManagerGlobalData>
|
|
||||||
+ Dispatch<ZcosmicOutputImageSourceManagerV1, ()>
|
|
||||||
+ Dispatch<ZcosmicImageSourceV1, ImageSourceData>
|
|
||||||
+ 'static,
|
|
||||||
{
|
|
||||||
fn bind(
|
|
||||||
_state: &mut D,
|
|
||||||
_handle: &DisplayHandle,
|
|
||||||
_client: &Client,
|
|
||||||
resource: New<ZcosmicOutputImageSourceManagerV1>,
|
|
||||||
_global_data: &OutputImageSourceManagerGlobalData,
|
|
||||||
data_init: &mut DataInit<'_, D>,
|
|
||||||
) {
|
|
||||||
data_init.init(resource, ());
|
|
||||||
}
|
|
||||||
|
|
||||||
fn can_view(client: Client, global_data: &OutputImageSourceManagerGlobalData) -> bool {
|
|
||||||
(global_data.filter)(&client)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<D>
|
|
||||||
GlobalDispatch<ZcosmicWorkspaceImageSourceManagerV1, WorkspaceImageSourceManagerGlobalData, D>
|
|
||||||
for ImageSourceState
|
|
||||||
where
|
|
||||||
D: GlobalDispatch<ZcosmicWorkspaceImageSourceManagerV1, WorkspaceImageSourceManagerGlobalData>
|
|
||||||
+ Dispatch<ZcosmicWorkspaceImageSourceManagerV1, ()>
|
|
||||||
+ Dispatch<ZcosmicImageSourceV1, ImageSourceData>
|
|
||||||
+ 'static,
|
|
||||||
{
|
|
||||||
fn bind(
|
|
||||||
_state: &mut D,
|
|
||||||
_handle: &DisplayHandle,
|
|
||||||
_client: &Client,
|
|
||||||
resource: New<ZcosmicWorkspaceImageSourceManagerV1>,
|
|
||||||
_global_data: &WorkspaceImageSourceManagerGlobalData,
|
|
||||||
data_init: &mut DataInit<'_, D>,
|
|
||||||
) {
|
|
||||||
data_init.init(resource, ());
|
|
||||||
}
|
|
||||||
|
|
||||||
fn can_view(client: Client, global_data: &WorkspaceImageSourceManagerGlobalData) -> bool {
|
|
||||||
(global_data.filter)(&client)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<D>
|
|
||||||
GlobalDispatch<
|
|
||||||
ZcosmicExtWorkspaceImageSourceManagerV1,
|
|
||||||
WorkspaceImageSourceManagerGlobalData,
|
|
||||||
D,
|
|
||||||
> for ImageSourceState
|
|
||||||
where
|
|
||||||
D: GlobalDispatch<
|
|
||||||
ZcosmicExtWorkspaceImageSourceManagerV1,
|
|
||||||
WorkspaceImageSourceManagerGlobalData,
|
|
||||||
> + Dispatch<ZcosmicExtWorkspaceImageSourceManagerV1, ()>
|
|
||||||
+ Dispatch<ZcosmicImageSourceV1, ImageSourceData>
|
|
||||||
+ 'static,
|
|
||||||
{
|
|
||||||
fn bind(
|
|
||||||
_state: &mut D,
|
|
||||||
_handle: &DisplayHandle,
|
|
||||||
_client: &Client,
|
|
||||||
resource: New<ZcosmicExtWorkspaceImageSourceManagerV1>,
|
|
||||||
_global_data: &WorkspaceImageSourceManagerGlobalData,
|
|
||||||
data_init: &mut DataInit<'_, D>,
|
|
||||||
) {
|
|
||||||
data_init.init(resource, ());
|
|
||||||
}
|
|
||||||
|
|
||||||
fn can_view(client: Client, global_data: &WorkspaceImageSourceManagerGlobalData) -> bool {
|
|
||||||
(global_data.filter)(&client)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<D> GlobalDispatch<ZcosmicToplevelImageSourceManagerV1, ToplevelImageSourceManagerGlobalData, D>
|
|
||||||
for ImageSourceState
|
|
||||||
where
|
|
||||||
D: GlobalDispatch<ZcosmicToplevelImageSourceManagerV1, ToplevelImageSourceManagerGlobalData>
|
|
||||||
+ Dispatch<ZcosmicToplevelImageSourceManagerV1, ()>
|
|
||||||
+ Dispatch<ZcosmicImageSourceV1, ImageSourceData>
|
|
||||||
+ 'static,
|
|
||||||
{
|
|
||||||
fn bind(
|
|
||||||
_state: &mut D,
|
|
||||||
_handle: &DisplayHandle,
|
|
||||||
_client: &Client,
|
|
||||||
resource: New<ZcosmicToplevelImageSourceManagerV1>,
|
|
||||||
_global_data: &ToplevelImageSourceManagerGlobalData,
|
|
||||||
data_init: &mut DataInit<'_, D>,
|
|
||||||
) {
|
|
||||||
data_init.init(resource, ());
|
|
||||||
}
|
|
||||||
|
|
||||||
fn can_view(client: Client, global_data: &ToplevelImageSourceManagerGlobalData) -> bool {
|
|
||||||
(global_data.filter)(&client)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<D> Dispatch<ZcosmicOutputImageSourceManagerV1, (), D> for ImageSourceState
|
|
||||||
where
|
|
||||||
D: Dispatch<ZcosmicOutputImageSourceManagerV1, ()>
|
|
||||||
+ Dispatch<ZcosmicImageSourceV1, ImageSourceData>
|
|
||||||
+ 'static,
|
|
||||||
{
|
|
||||||
fn request(
|
|
||||||
_state: &mut D,
|
|
||||||
_client: &Client,
|
|
||||||
_resource: &ZcosmicOutputImageSourceManagerV1,
|
|
||||||
request: <ZcosmicOutputImageSourceManagerV1 as Resource>::Request,
|
|
||||||
_data: &(),
|
|
||||||
_dhandle: &DisplayHandle,
|
|
||||||
data_init: &mut DataInit<'_, D>,
|
|
||||||
) {
|
|
||||||
match request {
|
|
||||||
OutputSourceRequest::CreateSource { source, output } => {
|
|
||||||
let data = match Output::from_resource(&output) {
|
|
||||||
Some(output) => ImageSourceData::Output(output.downgrade()),
|
|
||||||
None => ImageSourceData::Destroyed,
|
|
||||||
};
|
|
||||||
data_init.init(source, data);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn destroyed(
|
|
||||||
_state: &mut D,
|
|
||||||
_client: wayland_backend::server::ClientId,
|
|
||||||
_resource: &ZcosmicOutputImageSourceManagerV1,
|
|
||||||
_data: &(),
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<D> Dispatch<ZcosmicWorkspaceImageSourceManagerV1, (), D> for ImageSourceState
|
|
||||||
where
|
|
||||||
D: Dispatch<ZcosmicWorkspaceImageSourceManagerV1, ()>
|
|
||||||
+ Dispatch<ZcosmicImageSourceV1, ImageSourceData>
|
|
||||||
+ WorkspaceHandler
|
|
||||||
+ 'static,
|
|
||||||
{
|
|
||||||
fn request(
|
|
||||||
state: &mut D,
|
|
||||||
_client: &Client,
|
|
||||||
_resource: &ZcosmicWorkspaceImageSourceManagerV1,
|
|
||||||
request: <ZcosmicWorkspaceImageSourceManagerV1 as Resource>::Request,
|
|
||||||
_data: &(),
|
|
||||||
_dhandle: &DisplayHandle,
|
|
||||||
data_init: &mut DataInit<'_, D>,
|
|
||||||
) {
|
|
||||||
match request {
|
|
||||||
WorkspaceSourceRequest::CreateSource { source, output } => {
|
|
||||||
let data = match state.workspace_state().workspace_handle(&output) {
|
|
||||||
Some(workspace) => ImageSourceData::Workspace(workspace),
|
|
||||||
None => ImageSourceData::Destroyed,
|
|
||||||
};
|
|
||||||
data_init.init(source, data);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn destroyed(
|
|
||||||
_state: &mut D,
|
|
||||||
_client: wayland_backend::server::ClientId,
|
|
||||||
_resource: &ZcosmicWorkspaceImageSourceManagerV1,
|
|
||||||
_data: &(),
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<D> Dispatch<ZcosmicExtWorkspaceImageSourceManagerV1, (), D> for ImageSourceState
|
|
||||||
where
|
|
||||||
D: Dispatch<ZcosmicExtWorkspaceImageSourceManagerV1, ()>
|
|
||||||
+ Dispatch<ZcosmicImageSourceV1, ImageSourceData>
|
|
||||||
+ WorkspaceHandler
|
|
||||||
+ 'static,
|
|
||||||
{
|
|
||||||
fn request(
|
|
||||||
state: &mut D,
|
|
||||||
_client: &Client,
|
|
||||||
_resource: &ZcosmicExtWorkspaceImageSourceManagerV1,
|
|
||||||
request: <ZcosmicExtWorkspaceImageSourceManagerV1 as Resource>::Request,
|
|
||||||
_data: &(),
|
|
||||||
_dhandle: &DisplayHandle,
|
|
||||||
data_init: &mut DataInit<'_, D>,
|
|
||||||
) {
|
|
||||||
match request {
|
|
||||||
ExtWorkspaceSourceRequest::CreateSource { source, output } => {
|
|
||||||
let data = match state.workspace_state().get_ext_workspace_handle(&output) {
|
|
||||||
Some(workspace) => ImageSourceData::Workspace(workspace),
|
|
||||||
None => ImageSourceData::Destroyed,
|
|
||||||
};
|
|
||||||
data_init.init(source, data);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn destroyed(
|
|
||||||
_state: &mut D,
|
|
||||||
_client: wayland_backend::server::ClientId,
|
|
||||||
_resource: &ZcosmicExtWorkspaceImageSourceManagerV1,
|
|
||||||
_data: &(),
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<D> Dispatch<ZcosmicToplevelImageSourceManagerV1, (), D> for ImageSourceState
|
|
||||||
where
|
|
||||||
D: Dispatch<ZcosmicToplevelImageSourceManagerV1, ()>
|
|
||||||
+ Dispatch<ZcosmicImageSourceV1, ImageSourceData>
|
|
||||||
+ 'static,
|
|
||||||
{
|
|
||||||
fn request(
|
|
||||||
_state: &mut D,
|
|
||||||
_client: &Client,
|
|
||||||
_resource: &ZcosmicToplevelImageSourceManagerV1,
|
|
||||||
request: <ZcosmicToplevelImageSourceManagerV1 as Resource>::Request,
|
|
||||||
_data: &(),
|
|
||||||
_dhandle: &DisplayHandle,
|
|
||||||
data_init: &mut DataInit<'_, D>,
|
|
||||||
) {
|
|
||||||
match request {
|
|
||||||
ToplevelSourceRequest::CreateSource {
|
|
||||||
source,
|
|
||||||
toplevel_handle,
|
|
||||||
} => {
|
|
||||||
let data = match window_from_handle(toplevel_handle) {
|
|
||||||
Some(toplevel) => ImageSourceData::Toplevel(toplevel),
|
|
||||||
None => ImageSourceData::Destroyed,
|
|
||||||
};
|
|
||||||
data_init.init(source, data);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn destroyed(
|
|
||||||
_state: &mut D,
|
|
||||||
_client: wayland_backend::server::ClientId,
|
|
||||||
_resource: &ZcosmicToplevelImageSourceManagerV1,
|
|
||||||
_data: &(),
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<D> Dispatch<ZcosmicImageSourceV1, ImageSourceData, D> for ImageSourceState
|
|
||||||
where
|
|
||||||
D: Dispatch<ZcosmicImageSourceV1, ImageSourceData> + 'static,
|
|
||||||
{
|
|
||||||
fn request(
|
|
||||||
_state: &mut D,
|
|
||||||
_client: &Client,
|
|
||||||
_resource: &ZcosmicImageSourceV1,
|
|
||||||
request: <ZcosmicImageSourceV1 as Resource>::Request,
|
|
||||||
_data: &ImageSourceData,
|
|
||||||
_dhandle: &DisplayHandle,
|
|
||||||
_data_init: &mut DataInit<'_, D>,
|
|
||||||
) {
|
|
||||||
match request {
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn destroyed(
|
|
||||||
_state: &mut D,
|
|
||||||
_client: wayland_backend::server::ClientId,
|
|
||||||
_resource: &ZcosmicImageSourceV1,
|
|
||||||
_data: &ImageSourceData,
|
|
||||||
) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! delegate_image_source {
|
|
||||||
($(@<$( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+>)? $ty: ty) => {
|
|
||||||
smithay::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
|
||||||
cosmic_protocols::image_source::v1::server::zcosmic_output_image_source_manager_v1::ZcosmicOutputImageSourceManagerV1: $crate::wayland::protocols::image_source::OutputImageSourceManagerGlobalData
|
|
||||||
] => $crate::wayland::protocols::image_source::ImageSourceState);
|
|
||||||
smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
|
||||||
cosmic_protocols::image_source::v1::server::zcosmic_output_image_source_manager_v1::ZcosmicOutputImageSourceManagerV1: ()
|
|
||||||
] => $crate::wayland::protocols::image_source::ImageSourceState);
|
|
||||||
smithay::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
|
||||||
cosmic_protocols::image_source::v1::server::zcosmic_workspace_image_source_manager_v1::ZcosmicWorkspaceImageSourceManagerV1: $crate::wayland::protocols::image_source::WorkspaceImageSourceManagerGlobalData
|
|
||||||
] => $crate::wayland::protocols::image_source::ImageSourceState);
|
|
||||||
smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
|
||||||
cosmic_protocols::image_source::v1::server::zcosmic_workspace_image_source_manager_v1::ZcosmicWorkspaceImageSourceManagerV1: ()
|
|
||||||
] => $crate::wayland::protocols::image_source::ImageSourceState);
|
|
||||||
smithay::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
|
||||||
cosmic_protocols::image_source::v1::server::zcosmic_ext_workspace_image_source_manager_v1::ZcosmicExtWorkspaceImageSourceManagerV1: $crate::wayland::protocols::image_source::WorkspaceImageSourceManagerGlobalData
|
|
||||||
] => $crate::wayland::protocols::image_source::ImageSourceState);
|
|
||||||
smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
|
||||||
cosmic_protocols::image_source::v1::server::zcosmic_ext_workspace_image_source_manager_v1::ZcosmicExtWorkspaceImageSourceManagerV1: ()
|
|
||||||
] => $crate::wayland::protocols::image_source::ImageSourceState);
|
|
||||||
smithay::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
|
||||||
cosmic_protocols::image_source::v1::server::zcosmic_toplevel_image_source_manager_v1::ZcosmicToplevelImageSourceManagerV1: $crate::wayland::protocols::image_source::ToplevelImageSourceManagerGlobalData
|
|
||||||
] => $crate::wayland::protocols::image_source::ImageSourceState);
|
|
||||||
smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
|
||||||
cosmic_protocols::image_source::v1::server::zcosmic_toplevel_image_source_manager_v1::ZcosmicToplevelImageSourceManagerV1: ()
|
|
||||||
] => $crate::wayland::protocols::image_source::ImageSourceState);
|
|
||||||
smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
|
||||||
cosmic_protocols::image_source::v1::server::zcosmic_image_source_v1::ZcosmicImageSourceV1: $crate::wayland::protocols::image_source::ImageSourceData
|
|
||||||
] => $crate::wayland::protocols::image_source::ImageSourceState);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
pub(crate) use delegate_image_source;
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
pub mod a11y;
|
pub mod a11y;
|
||||||
pub mod atspi;
|
pub mod atspi;
|
||||||
pub mod drm;
|
pub mod drm;
|
||||||
pub mod image_source;
|
pub mod image_capture_source;
|
||||||
pub mod output_configuration;
|
pub mod output_configuration;
|
||||||
pub mod output_power;
|
pub mod output_power;
|
||||||
pub mod overlap_notify;
|
pub mod overlap_notify;
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,14 @@ use std::{
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub use cosmic_protocols::screencopy::v2::server::zcosmic_screencopy_frame_v2::FailureReason;
|
pub use smithay::reexports::wayland_protocols::ext::image_copy_capture::v1::server::{
|
||||||
use cosmic_protocols::screencopy::v2::server::{
|
ext_image_copy_capture_frame_v1::FailureReason,
|
||||||
zcosmic_screencopy_cursor_session_v2::{self, ZcosmicScreencopyCursorSessionV2},
|
};
|
||||||
zcosmic_screencopy_frame_v2::{self, ZcosmicScreencopyFrameV2},
|
use smithay::reexports::wayland_protocols::ext::image_copy_capture::v1::server::{
|
||||||
zcosmic_screencopy_manager_v2::{self, ZcosmicScreencopyManagerV2},
|
ext_image_copy_capture_cursor_session_v1::{self, ExtImageCopyCaptureCursorSessionV1},
|
||||||
zcosmic_screencopy_session_v2::{self, ZcosmicScreencopySessionV2},
|
ext_image_copy_capture_frame_v1::{self, ExtImageCopyCaptureFrameV1},
|
||||||
|
ext_image_copy_capture_manager_v1::{self, ExtImageCopyCaptureManagerV1},
|
||||||
|
ext_image_copy_capture_session_v1::{self, ExtImageCopyCaptureSessionV1},
|
||||||
};
|
};
|
||||||
use smithay::{
|
use smithay::{
|
||||||
backend::{
|
backend::{
|
||||||
|
|
@ -30,7 +32,7 @@ use smithay::{
|
||||||
use tracing::debug;
|
use tracing::debug;
|
||||||
use wayland_backend::server::GlobalId;
|
use wayland_backend::server::GlobalId;
|
||||||
|
|
||||||
use super::image_source::ImageSourceData;
|
use super::image_capture_source::ImageCaptureSourceData;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct ScreencopyState {
|
pub struct ScreencopyState {
|
||||||
|
|
@ -42,18 +44,18 @@ pub struct ScreencopyState {
|
||||||
impl ScreencopyState {
|
impl ScreencopyState {
|
||||||
pub fn new<D, F>(display: &DisplayHandle, client_filter: F) -> ScreencopyState
|
pub fn new<D, F>(display: &DisplayHandle, client_filter: F) -> ScreencopyState
|
||||||
where
|
where
|
||||||
D: GlobalDispatch<ZcosmicScreencopyManagerV2, ScreencopyGlobalData>
|
D: GlobalDispatch<ExtImageCopyCaptureManagerV1, ScreencopyGlobalData>
|
||||||
+ Dispatch<ZcosmicScreencopyManagerV2, ScreencopyData>
|
+ Dispatch<ExtImageCopyCaptureManagerV1, ScreencopyData>
|
||||||
+ Dispatch<ZcosmicScreencopySessionV2, SessionData>
|
+ Dispatch<ExtImageCopyCaptureSessionV1, SessionData>
|
||||||
+ Dispatch<ZcosmicScreencopySessionV2, CursorSessionData>
|
+ Dispatch<ExtImageCopyCaptureSessionV1, CursorSessionData>
|
||||||
+ Dispatch<ZcosmicScreencopyCursorSessionV2, CursorSessionData>
|
+ Dispatch<ExtImageCopyCaptureCursorSessionV1, CursorSessionData>
|
||||||
+ Dispatch<ZcosmicScreencopyFrameV2, FrameData>
|
+ Dispatch<ExtImageCopyCaptureFrameV1, FrameData>
|
||||||
+ ScreencopyHandler
|
+ ScreencopyHandler
|
||||||
+ 'static,
|
+ 'static,
|
||||||
F: for<'a> Fn(&'a Client) -> bool + Send + Sync + 'static,
|
F: for<'a> Fn(&'a Client) -> bool + Send + Sync + 'static,
|
||||||
{
|
{
|
||||||
ScreencopyState {
|
ScreencopyState {
|
||||||
global: display.create_global::<D, ZcosmicScreencopyManagerV2, _>(
|
global: display.create_global::<D, ExtImageCopyCaptureManagerV1, _>(
|
||||||
1,
|
1,
|
||||||
ScreencopyGlobalData {
|
ScreencopyGlobalData {
|
||||||
filter: Box::new(client_filter),
|
filter: Box::new(client_filter),
|
||||||
|
|
@ -84,7 +86,7 @@ pub struct DmabufConstraints {
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Session {
|
pub struct Session {
|
||||||
obj: ZcosmicScreencopySessionV2,
|
obj: ExtImageCopyCaptureSessionV1,
|
||||||
inner: Arc<Mutex<SessionInner>>,
|
inner: Arc<Mutex<SessionInner>>,
|
||||||
user_data: Arc<UserDataMap>,
|
user_data: Arc<UserDataMap>,
|
||||||
}
|
}
|
||||||
|
|
@ -100,12 +102,12 @@ struct SessionInner {
|
||||||
stopped: bool,
|
stopped: bool,
|
||||||
constraints: Option<BufferConstraints>,
|
constraints: Option<BufferConstraints>,
|
||||||
draw_cursors: bool,
|
draw_cursors: bool,
|
||||||
source: ImageSourceData,
|
source: ImageCaptureSourceData,
|
||||||
active_frames: Vec<Frame>,
|
active_frames: Vec<Frame>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SessionInner {
|
impl SessionInner {
|
||||||
fn new(source: ImageSourceData, draw_cursors: bool) -> SessionInner {
|
fn new(source: ImageCaptureSourceData, draw_cursors: bool) -> SessionInner {
|
||||||
SessionInner {
|
SessionInner {
|
||||||
stopped: false,
|
stopped: false,
|
||||||
constraints: None,
|
constraints: None,
|
||||||
|
|
@ -133,7 +135,7 @@ impl Session {
|
||||||
self.obj
|
self.obj
|
||||||
.buffer_size(constraints.size.w as u32, constraints.size.h as u32);
|
.buffer_size(constraints.size.w as u32, constraints.size.h as u32);
|
||||||
for fmt in &constraints.shm {
|
for fmt in &constraints.shm {
|
||||||
self.obj.shm_format(*fmt as u32);
|
self.obj.shm_format(*fmt);
|
||||||
}
|
}
|
||||||
if let Some(dma) = constraints.dma.as_ref() {
|
if let Some(dma) = constraints.dma.as_ref() {
|
||||||
let node = Vec::from(dma.node.dev_id().to_ne_bytes());
|
let node = Vec::from(dma.node.dev_id().to_ne_bytes());
|
||||||
|
|
@ -155,7 +157,7 @@ impl Session {
|
||||||
self.inner.lock().unwrap().constraints.clone()
|
self.inner.lock().unwrap().constraints.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn source(&self) -> ImageSourceData {
|
pub fn source(&self) -> ImageCaptureSourceData {
|
||||||
self.inner.lock().unwrap().source.clone()
|
self.inner.lock().unwrap().source.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -186,7 +188,7 @@ impl Session {
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct CursorSession {
|
pub struct CursorSession {
|
||||||
obj: ZcosmicScreencopyCursorSessionV2,
|
obj: ExtImageCopyCaptureCursorSessionV1,
|
||||||
inner: Arc<Mutex<CursorSessionInner>>,
|
inner: Arc<Mutex<CursorSessionInner>>,
|
||||||
user_data: Arc<UserDataMap>,
|
user_data: Arc<UserDataMap>,
|
||||||
}
|
}
|
||||||
|
|
@ -199,17 +201,17 @@ impl PartialEq for CursorSession {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct CursorSessionInner {
|
struct CursorSessionInner {
|
||||||
session: Option<ZcosmicScreencopySessionV2>,
|
session: Option<ExtImageCopyCaptureSessionV1>,
|
||||||
stopped: bool,
|
stopped: bool,
|
||||||
constraints: Option<BufferConstraints>,
|
constraints: Option<BufferConstraints>,
|
||||||
source: ImageSourceData,
|
source: ImageCaptureSourceData,
|
||||||
position: Option<Point<i32, BufferCoords>>,
|
position: Option<Point<i32, BufferCoords>>,
|
||||||
hotspot: Point<i32, BufferCoords>,
|
hotspot: Point<i32, BufferCoords>,
|
||||||
active_frames: Vec<Frame>,
|
active_frames: Vec<Frame>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CursorSessionInner {
|
impl CursorSessionInner {
|
||||||
fn new(source: ImageSourceData) -> CursorSessionInner {
|
fn new(source: ImageCaptureSourceData) -> CursorSessionInner {
|
||||||
CursorSessionInner {
|
CursorSessionInner {
|
||||||
session: None,
|
session: None,
|
||||||
stopped: false,
|
stopped: false,
|
||||||
|
|
@ -239,7 +241,7 @@ impl CursorSession {
|
||||||
if let Some(session_obj) = inner.session.as_ref() {
|
if let Some(session_obj) = inner.session.as_ref() {
|
||||||
session_obj.buffer_size(constrains.size.w as u32, constrains.size.h as u32);
|
session_obj.buffer_size(constrains.size.w as u32, constrains.size.h as u32);
|
||||||
for fmt in &constrains.shm {
|
for fmt in &constrains.shm {
|
||||||
session_obj.shm_format(*fmt as u32);
|
session_obj.shm_format(*fmt);
|
||||||
}
|
}
|
||||||
if let Some(dma) = constrains.dma.as_ref() {
|
if let Some(dma) = constrains.dma.as_ref() {
|
||||||
let node = Vec::from(dma.node.dev_id().to_ne_bytes());
|
let node = Vec::from(dma.node.dev_id().to_ne_bytes());
|
||||||
|
|
@ -262,7 +264,7 @@ impl CursorSession {
|
||||||
self.inner.lock().unwrap().constraints.clone()
|
self.inner.lock().unwrap().constraints.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn source(&self) -> ImageSourceData {
|
pub fn source(&self) -> ImageCaptureSourceData {
|
||||||
self.inner.lock().unwrap().source.clone()
|
self.inner.lock().unwrap().source.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -340,7 +342,7 @@ impl CursorSession {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Frame {
|
pub struct Frame {
|
||||||
obj: ZcosmicScreencopyFrameV2,
|
obj: ExtImageCopyCaptureFrameV1,
|
||||||
inner: Arc<Mutex<FrameInner>>,
|
inner: Arc<Mutex<FrameInner>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -404,7 +406,7 @@ struct FrameInner {
|
||||||
damage: Vec<Rectangle<i32, BufferCoords>>,
|
damage: Vec<Rectangle<i32, BufferCoords>>,
|
||||||
// `SessionInner` contains a `Vec<Frame>`, so use a weak reference here to
|
// `SessionInner` contains a `Vec<Frame>`, so use a weak reference here to
|
||||||
// avoid a cycle.
|
// avoid a cycle.
|
||||||
obj: Weak<ZcosmicScreencopySessionV2>,
|
obj: Weak<ExtImageCopyCaptureSessionV1>,
|
||||||
capture_requested: bool,
|
capture_requested: bool,
|
||||||
failed: Option<FailureReason>,
|
failed: Option<FailureReason>,
|
||||||
ready: bool,
|
ready: bool,
|
||||||
|
|
@ -412,7 +414,7 @@ struct FrameInner {
|
||||||
|
|
||||||
impl FrameInner {
|
impl FrameInner {
|
||||||
fn new(
|
fn new(
|
||||||
obj: ZcosmicScreencopySessionV2,
|
obj: ExtImageCopyCaptureSessionV1,
|
||||||
constraints: impl Into<Option<BufferConstraints>>,
|
constraints: impl Into<Option<BufferConstraints>>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
FrameInner {
|
FrameInner {
|
||||||
|
|
@ -426,7 +428,7 @@ impl FrameInner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fail(&mut self, frame: &ZcosmicScreencopyFrameV2, reason: FailureReason) {
|
fn fail(&mut self, frame: &ExtImageCopyCaptureFrameV1, reason: FailureReason) {
|
||||||
if self.ready || self.failed.is_some() {
|
if self.ready || self.failed.is_some() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -440,8 +442,11 @@ impl FrameInner {
|
||||||
pub trait ScreencopyHandler {
|
pub trait ScreencopyHandler {
|
||||||
fn screencopy_state(&mut self) -> &mut ScreencopyState;
|
fn screencopy_state(&mut self) -> &mut ScreencopyState;
|
||||||
|
|
||||||
fn capture_source(&mut self, source: &ImageSourceData) -> Option<BufferConstraints>;
|
fn capture_source(&mut self, source: &ImageCaptureSourceData) -> Option<BufferConstraints>;
|
||||||
fn capture_cursor_source(&mut self, source: &ImageSourceData) -> Option<BufferConstraints>;
|
fn capture_cursor_source(
|
||||||
|
&mut self,
|
||||||
|
source: &ImageCaptureSourceData,
|
||||||
|
) -> Option<BufferConstraints>;
|
||||||
|
|
||||||
fn new_session(&mut self, session: Session);
|
fn new_session(&mut self, session: Session);
|
||||||
fn new_cursor_session(&mut self, session: CursorSession);
|
fn new_cursor_session(&mut self, session: CursorSession);
|
||||||
|
|
@ -475,14 +480,14 @@ pub struct FrameData {
|
||||||
inner: Arc<Mutex<FrameInner>>,
|
inner: Arc<Mutex<FrameInner>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D> GlobalDispatch<ZcosmicScreencopyManagerV2, ScreencopyGlobalData, D> for ScreencopyState
|
impl<D> GlobalDispatch<ExtImageCopyCaptureManagerV1, ScreencopyGlobalData, D> for ScreencopyState
|
||||||
where
|
where
|
||||||
D: GlobalDispatch<ZcosmicScreencopyManagerV2, ScreencopyGlobalData>
|
D: GlobalDispatch<ExtImageCopyCaptureManagerV1, ScreencopyGlobalData>
|
||||||
+ Dispatch<ZcosmicScreencopyManagerV2, ScreencopyData>
|
+ Dispatch<ExtImageCopyCaptureManagerV1, ScreencopyData>
|
||||||
+ Dispatch<ZcosmicScreencopySessionV2, SessionData>
|
+ Dispatch<ExtImageCopyCaptureSessionV1, SessionData>
|
||||||
+ Dispatch<ZcosmicScreencopySessionV2, CursorSessionData>
|
+ Dispatch<ExtImageCopyCaptureSessionV1, CursorSessionData>
|
||||||
+ Dispatch<ZcosmicScreencopyCursorSessionV2, CursorSessionData>
|
+ Dispatch<ExtImageCopyCaptureCursorSessionV1, CursorSessionData>
|
||||||
+ Dispatch<ZcosmicScreencopyFrameV2, FrameData>
|
+ Dispatch<ExtImageCopyCaptureFrameV1, FrameData>
|
||||||
+ ScreencopyHandler
|
+ ScreencopyHandler
|
||||||
+ 'static,
|
+ 'static,
|
||||||
{
|
{
|
||||||
|
|
@ -490,7 +495,7 @@ where
|
||||||
_state: &mut D,
|
_state: &mut D,
|
||||||
_handle: &DisplayHandle,
|
_handle: &DisplayHandle,
|
||||||
_client: &Client,
|
_client: &Client,
|
||||||
resource: New<ZcosmicScreencopyManagerV2>,
|
resource: New<ExtImageCopyCaptureManagerV1>,
|
||||||
_global_data: &ScreencopyGlobalData,
|
_global_data: &ScreencopyGlobalData,
|
||||||
data_init: &mut DataInit<'_, D>,
|
data_init: &mut DataInit<'_, D>,
|
||||||
) {
|
) {
|
||||||
|
|
@ -502,33 +507,33 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D> Dispatch<ZcosmicScreencopyManagerV2, ScreencopyData, D> for ScreencopyState
|
impl<D> Dispatch<ExtImageCopyCaptureManagerV1, ScreencopyData, D> for ScreencopyState
|
||||||
where
|
where
|
||||||
D: Dispatch<ZcosmicScreencopyManagerV2, ScreencopyData>
|
D: Dispatch<ExtImageCopyCaptureManagerV1, ScreencopyData>
|
||||||
+ Dispatch<ZcosmicScreencopySessionV2, SessionData>
|
+ Dispatch<ExtImageCopyCaptureSessionV1, SessionData>
|
||||||
+ Dispatch<ZcosmicScreencopySessionV2, CursorSessionData>
|
+ Dispatch<ExtImageCopyCaptureSessionV1, CursorSessionData>
|
||||||
+ Dispatch<ZcosmicScreencopyCursorSessionV2, CursorSessionData>
|
+ Dispatch<ExtImageCopyCaptureCursorSessionV1, CursorSessionData>
|
||||||
+ Dispatch<ZcosmicScreencopyFrameV2, FrameData>
|
+ Dispatch<ExtImageCopyCaptureFrameV1, FrameData>
|
||||||
+ ScreencopyHandler
|
+ ScreencopyHandler
|
||||||
+ 'static,
|
+ 'static,
|
||||||
{
|
{
|
||||||
fn request(
|
fn request(
|
||||||
state: &mut D,
|
state: &mut D,
|
||||||
_client: &Client,
|
_client: &Client,
|
||||||
_resource: &ZcosmicScreencopyManagerV2,
|
_resource: &ExtImageCopyCaptureManagerV1,
|
||||||
request: <ZcosmicScreencopyManagerV2 as Resource>::Request,
|
request: <ExtImageCopyCaptureManagerV1 as Resource>::Request,
|
||||||
_data: &ScreencopyData,
|
_data: &ScreencopyData,
|
||||||
_dhandle: &DisplayHandle,
|
_dhandle: &DisplayHandle,
|
||||||
data_init: &mut DataInit<'_, D>,
|
data_init: &mut DataInit<'_, D>,
|
||||||
) {
|
) {
|
||||||
match request {
|
match request {
|
||||||
zcosmic_screencopy_manager_v2::Request::CreateSession {
|
ext_image_copy_capture_manager_v1::Request::CreateSession {
|
||||||
session,
|
session,
|
||||||
source,
|
source,
|
||||||
options,
|
options,
|
||||||
} => {
|
} => {
|
||||||
if let Some(src) = source.data::<ImageSourceData>() {
|
if let Some(src) = source.data::<ImageCaptureSourceData>() {
|
||||||
if *src != ImageSourceData::Destroyed {
|
if *src != ImageCaptureSourceData::Destroyed {
|
||||||
if let Some(buffer_constraints) = state.capture_source(src) {
|
if let Some(buffer_constraints) = state.capture_source(src) {
|
||||||
let session_data = Arc::new(Mutex::new(SessionInner::new(
|
let session_data = Arc::new(Mutex::new(SessionInner::new(
|
||||||
src.clone(),
|
src.clone(),
|
||||||
|
|
@ -558,7 +563,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
let session_data = Arc::new(Mutex::new(SessionInner::new(
|
let session_data = Arc::new(Mutex::new(SessionInner::new(
|
||||||
ImageSourceData::Destroyed,
|
ImageCaptureSourceData::Destroyed,
|
||||||
false,
|
false,
|
||||||
)));
|
)));
|
||||||
let obj = data_init.init(
|
let obj = data_init.init(
|
||||||
|
|
@ -574,16 +579,15 @@ where
|
||||||
};
|
};
|
||||||
session.stop();
|
session.stop();
|
||||||
}
|
}
|
||||||
zcosmic_screencopy_manager_v2::Request::CreatePointerCursorSession {
|
ext_image_copy_capture_manager_v1::Request::CreatePointerCursorSession {
|
||||||
session,
|
session,
|
||||||
source,
|
source,
|
||||||
pointer: _,
|
pointer: _,
|
||||||
options: _,
|
|
||||||
} => {
|
} => {
|
||||||
// TODO: use pointer, but we need new smithay api for that.
|
// TODO: use pointer, but we need new smithay api for that.
|
||||||
|
|
||||||
if let Some(src) = source.data::<ImageSourceData>() {
|
if let Some(src) = source.data::<ImageCaptureSourceData>() {
|
||||||
if *src != ImageSourceData::Destroyed {
|
if *src != ImageCaptureSourceData::Destroyed {
|
||||||
if let Some(buffer_constraints) = state.capture_cursor_source(src) {
|
if let Some(buffer_constraints) = state.capture_cursor_source(src) {
|
||||||
let session_data =
|
let session_data =
|
||||||
Arc::new(Mutex::new(CursorSessionInner::new(src.clone())));
|
Arc::new(Mutex::new(CursorSessionInner::new(src.clone())));
|
||||||
|
|
@ -611,7 +615,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
let session_data = Arc::new(Mutex::new(CursorSessionInner::new(
|
let session_data = Arc::new(Mutex::new(CursorSessionInner::new(
|
||||||
ImageSourceData::Destroyed,
|
ImageCaptureSourceData::Destroyed,
|
||||||
)));
|
)));
|
||||||
let obj = data_init.init(
|
let obj = data_init.init(
|
||||||
session,
|
session,
|
||||||
|
|
@ -633,30 +637,30 @@ where
|
||||||
fn destroyed(
|
fn destroyed(
|
||||||
_state: &mut D,
|
_state: &mut D,
|
||||||
_client: wayland_backend::server::ClientId,
|
_client: wayland_backend::server::ClientId,
|
||||||
_resource: &ZcosmicScreencopyManagerV2,
|
_resource: &ExtImageCopyCaptureManagerV1,
|
||||||
_data: &ScreencopyData,
|
_data: &ScreencopyData,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D> Dispatch<ZcosmicScreencopySessionV2, SessionData, D> for ScreencopyState
|
impl<D> Dispatch<ExtImageCopyCaptureSessionV1, SessionData, D> for ScreencopyState
|
||||||
where
|
where
|
||||||
D: Dispatch<ZcosmicScreencopySessionV2, SessionData>
|
D: Dispatch<ExtImageCopyCaptureSessionV1, SessionData>
|
||||||
+ Dispatch<ZcosmicScreencopyFrameV2, FrameData>
|
+ Dispatch<ExtImageCopyCaptureFrameV1, FrameData>
|
||||||
+ ScreencopyHandler
|
+ ScreencopyHandler
|
||||||
+ 'static,
|
+ 'static,
|
||||||
{
|
{
|
||||||
fn request(
|
fn request(
|
||||||
_state: &mut D,
|
_state: &mut D,
|
||||||
_client: &Client,
|
_client: &Client,
|
||||||
resource: &ZcosmicScreencopySessionV2,
|
resource: &ExtImageCopyCaptureSessionV1,
|
||||||
request: <ZcosmicScreencopySessionV2 as Resource>::Request,
|
request: <ExtImageCopyCaptureSessionV1 as Resource>::Request,
|
||||||
data: &SessionData,
|
data: &SessionData,
|
||||||
_dhandle: &DisplayHandle,
|
_dhandle: &DisplayHandle,
|
||||||
data_init: &mut DataInit<'_, D>,
|
data_init: &mut DataInit<'_, D>,
|
||||||
) {
|
) {
|
||||||
match request {
|
match request {
|
||||||
zcosmic_screencopy_session_v2::Request::CreateFrame { frame } => {
|
ext_image_copy_capture_session_v1::Request::CreateFrame { frame } => {
|
||||||
let inner = Arc::new(Mutex::new(FrameInner::new(
|
let inner = Arc::new(Mutex::new(FrameInner::new(
|
||||||
resource.clone(),
|
resource.clone(),
|
||||||
data.inner.lock().unwrap().constraints.clone(),
|
data.inner.lock().unwrap().constraints.clone(),
|
||||||
|
|
@ -680,7 +684,7 @@ where
|
||||||
fn destroyed(
|
fn destroyed(
|
||||||
state: &mut D,
|
state: &mut D,
|
||||||
_client: wayland_backend::server::ClientId,
|
_client: wayland_backend::server::ClientId,
|
||||||
resource: &ZcosmicScreencopySessionV2,
|
resource: &ExtImageCopyCaptureSessionV1,
|
||||||
_data: &SessionData,
|
_data: &SessionData,
|
||||||
) {
|
) {
|
||||||
let scpy = state.screencopy_state();
|
let scpy = state.screencopy_state();
|
||||||
|
|
@ -695,25 +699,25 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D> Dispatch<ZcosmicScreencopyCursorSessionV2, CursorSessionData, D> for ScreencopyState
|
impl<D> Dispatch<ExtImageCopyCaptureCursorSessionV1, CursorSessionData, D> for ScreencopyState
|
||||||
where
|
where
|
||||||
D: Dispatch<ZcosmicScreencopyCursorSessionV2, CursorSessionData>
|
D: Dispatch<ExtImageCopyCaptureCursorSessionV1, CursorSessionData>
|
||||||
+ Dispatch<ZcosmicScreencopySessionV2, CursorSessionData>
|
+ Dispatch<ExtImageCopyCaptureSessionV1, CursorSessionData>
|
||||||
+ Dispatch<ZcosmicScreencopyFrameV2, FrameData>
|
+ Dispatch<ExtImageCopyCaptureFrameV1, FrameData>
|
||||||
+ ScreencopyHandler
|
+ ScreencopyHandler
|
||||||
+ 'static,
|
+ 'static,
|
||||||
{
|
{
|
||||||
fn request(
|
fn request(
|
||||||
_state: &mut D,
|
_state: &mut D,
|
||||||
_client: &Client,
|
_client: &Client,
|
||||||
resource: &ZcosmicScreencopyCursorSessionV2,
|
resource: &ExtImageCopyCaptureCursorSessionV1,
|
||||||
request: <ZcosmicScreencopyCursorSessionV2 as Resource>::Request,
|
request: <ExtImageCopyCaptureCursorSessionV1 as Resource>::Request,
|
||||||
data: &CursorSessionData,
|
data: &CursorSessionData,
|
||||||
_dhandle: &DisplayHandle,
|
_dhandle: &DisplayHandle,
|
||||||
data_init: &mut DataInit<'_, D>,
|
data_init: &mut DataInit<'_, D>,
|
||||||
) {
|
) {
|
||||||
match request {
|
match request {
|
||||||
zcosmic_screencopy_cursor_session_v2::Request::GetScreencopySession { session } => {
|
ext_image_copy_capture_cursor_session_v1::Request::GetCaptureSession { session } => {
|
||||||
let new_data = CursorSessionData {
|
let new_data = CursorSessionData {
|
||||||
inner: data.inner.clone(),
|
inner: data.inner.clone(),
|
||||||
};
|
};
|
||||||
|
|
@ -722,7 +726,7 @@ where
|
||||||
let mut inner = data.inner.lock().unwrap();
|
let mut inner = data.inner.lock().unwrap();
|
||||||
if inner.session.is_some() {
|
if inner.session.is_some() {
|
||||||
resource.post_error(
|
resource.post_error(
|
||||||
zcosmic_screencopy_cursor_session_v2::Error::DuplicateSession,
|
ext_image_copy_capture_cursor_session_v1::Error::DuplicateSession,
|
||||||
"Duplicate session",
|
"Duplicate session",
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
|
@ -733,7 +737,7 @@ where
|
||||||
} else if let Some(constraints) = inner.constraints.as_ref() {
|
} else if let Some(constraints) = inner.constraints.as_ref() {
|
||||||
session.buffer_size(constraints.size.w as u32, constraints.size.h as u32);
|
session.buffer_size(constraints.size.w as u32, constraints.size.h as u32);
|
||||||
for fmt in &constraints.shm {
|
for fmt in &constraints.shm {
|
||||||
session.shm_format(*fmt as u32);
|
session.shm_format(*fmt);
|
||||||
}
|
}
|
||||||
if let Some(dma) = constraints.dma.as_ref() {
|
if let Some(dma) = constraints.dma.as_ref() {
|
||||||
let node = Vec::from(dma.node.dev_id().to_ne_bytes());
|
let node = Vec::from(dma.node.dev_id().to_ne_bytes());
|
||||||
|
|
@ -757,7 +761,7 @@ where
|
||||||
fn destroyed(
|
fn destroyed(
|
||||||
state: &mut D,
|
state: &mut D,
|
||||||
_client: wayland_backend::server::ClientId,
|
_client: wayland_backend::server::ClientId,
|
||||||
resource: &ZcosmicScreencopyCursorSessionV2,
|
resource: &ExtImageCopyCaptureCursorSessionV1,
|
||||||
_data: &CursorSessionData,
|
_data: &CursorSessionData,
|
||||||
) {
|
) {
|
||||||
let scpy = state.screencopy_state();
|
let scpy = state.screencopy_state();
|
||||||
|
|
@ -772,24 +776,24 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D> Dispatch<ZcosmicScreencopySessionV2, CursorSessionData, D> for ScreencopyState
|
impl<D> Dispatch<ExtImageCopyCaptureSessionV1, CursorSessionData, D> for ScreencopyState
|
||||||
where
|
where
|
||||||
D: Dispatch<ZcosmicScreencopySessionV2, SessionData>
|
D: Dispatch<ExtImageCopyCaptureSessionV1, SessionData>
|
||||||
+ Dispatch<ZcosmicScreencopyFrameV2, FrameData>
|
+ Dispatch<ExtImageCopyCaptureFrameV1, FrameData>
|
||||||
+ ScreencopyHandler
|
+ ScreencopyHandler
|
||||||
+ 'static,
|
+ 'static,
|
||||||
{
|
{
|
||||||
fn request(
|
fn request(
|
||||||
_state: &mut D,
|
_state: &mut D,
|
||||||
_client: &Client,
|
_client: &Client,
|
||||||
resource: &ZcosmicScreencopySessionV2,
|
resource: &ExtImageCopyCaptureSessionV1,
|
||||||
request: <ZcosmicScreencopySessionV2 as Resource>::Request,
|
request: <ExtImageCopyCaptureSessionV1 as Resource>::Request,
|
||||||
data: &CursorSessionData,
|
data: &CursorSessionData,
|
||||||
_dhandle: &DisplayHandle,
|
_dhandle: &DisplayHandle,
|
||||||
data_init: &mut DataInit<'_, D>,
|
data_init: &mut DataInit<'_, D>,
|
||||||
) {
|
) {
|
||||||
match request {
|
match request {
|
||||||
zcosmic_screencopy_session_v2::Request::CreateFrame { frame } => {
|
ext_image_copy_capture_session_v1::Request::CreateFrame { frame } => {
|
||||||
let inner = Arc::new(Mutex::new(FrameInner::new(
|
let inner = Arc::new(Mutex::new(FrameInner::new(
|
||||||
resource.clone(),
|
resource.clone(),
|
||||||
data.inner.lock().unwrap().constraints.clone(),
|
data.inner.lock().unwrap().constraints.clone(),
|
||||||
|
|
@ -813,39 +817,39 @@ where
|
||||||
fn destroyed(
|
fn destroyed(
|
||||||
_state: &mut D,
|
_state: &mut D,
|
||||||
_client: wayland_backend::server::ClientId,
|
_client: wayland_backend::server::ClientId,
|
||||||
_resource: &ZcosmicScreencopySessionV2,
|
_resource: &ExtImageCopyCaptureSessionV1,
|
||||||
_data: &CursorSessionData,
|
_data: &CursorSessionData,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D> Dispatch<ZcosmicScreencopyFrameV2, FrameData, D> for ScreencopyState
|
impl<D> Dispatch<ExtImageCopyCaptureFrameV1, FrameData, D> for ScreencopyState
|
||||||
where
|
where
|
||||||
D: Dispatch<ZcosmicScreencopyFrameV2, FrameData> + ScreencopyHandler + 'static,
|
D: Dispatch<ExtImageCopyCaptureFrameV1, FrameData> + ScreencopyHandler + 'static,
|
||||||
{
|
{
|
||||||
fn request(
|
fn request(
|
||||||
state: &mut D,
|
state: &mut D,
|
||||||
_client: &Client,
|
_client: &Client,
|
||||||
resource: &ZcosmicScreencopyFrameV2,
|
resource: &ExtImageCopyCaptureFrameV1,
|
||||||
request: <ZcosmicScreencopyFrameV2 as Resource>::Request,
|
request: <ExtImageCopyCaptureFrameV1 as Resource>::Request,
|
||||||
data: &FrameData,
|
data: &FrameData,
|
||||||
_dhandle: &DisplayHandle,
|
_dhandle: &DisplayHandle,
|
||||||
_data_init: &mut DataInit<'_, D>,
|
_data_init: &mut DataInit<'_, D>,
|
||||||
) {
|
) {
|
||||||
match request {
|
match request {
|
||||||
zcosmic_screencopy_frame_v2::Request::AttachBuffer { buffer } => {
|
ext_image_copy_capture_frame_v1::Request::AttachBuffer { buffer } => {
|
||||||
let mut inner = data.inner.lock().unwrap();
|
let mut inner = data.inner.lock().unwrap();
|
||||||
|
|
||||||
if inner.capture_requested {
|
if inner.capture_requested {
|
||||||
resource.post_error(
|
resource.post_error(
|
||||||
zcosmic_screencopy_frame_v2::Error::AlreadyCaptured,
|
ext_image_copy_capture_frame_v1::Error::AlreadyCaptured,
|
||||||
"Frame was captured previously",
|
"Frame was captured previously",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
inner.buffer = Some(buffer);
|
inner.buffer = Some(buffer);
|
||||||
}
|
}
|
||||||
zcosmic_screencopy_frame_v2::Request::DamageBuffer {
|
ext_image_copy_capture_frame_v1::Request::DamageBuffer {
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
width,
|
width,
|
||||||
|
|
@ -855,14 +859,14 @@ where
|
||||||
|
|
||||||
if inner.capture_requested {
|
if inner.capture_requested {
|
||||||
resource.post_error(
|
resource.post_error(
|
||||||
zcosmic_screencopy_frame_v2::Error::AlreadyCaptured,
|
ext_image_copy_capture_frame_v1::Error::AlreadyCaptured,
|
||||||
"Frame was captured previously",
|
"Frame was captured previously",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if x < 0 || y < 0 || width <= 0 || height <= 0 {
|
if x < 0 || y < 0 || width <= 0 || height <= 0 {
|
||||||
resource.post_error(
|
resource.post_error(
|
||||||
zcosmic_screencopy_frame_v2::Error::InvalidBufferDamage,
|
ext_image_copy_capture_frame_v1::Error::InvalidBufferDamage,
|
||||||
"Coordinates negative or size equal to zero",
|
"Coordinates negative or size equal to zero",
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
|
|
@ -872,19 +876,19 @@ where
|
||||||
.damage
|
.damage
|
||||||
.push(Rectangle::new((x, y).into(), (width, height).into()));
|
.push(Rectangle::new((x, y).into(), (width, height).into()));
|
||||||
}
|
}
|
||||||
zcosmic_screencopy_frame_v2::Request::Capture => {
|
ext_image_copy_capture_frame_v1::Request::Capture => {
|
||||||
let mut inner = data.inner.lock().unwrap();
|
let mut inner = data.inner.lock().unwrap();
|
||||||
|
|
||||||
if inner.capture_requested {
|
if inner.capture_requested {
|
||||||
resource.post_error(
|
resource.post_error(
|
||||||
zcosmic_screencopy_frame_v2::Error::AlreadyCaptured,
|
ext_image_copy_capture_frame_v1::Error::AlreadyCaptured,
|
||||||
"Frame was captured previously",
|
"Frame was captured previously",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if inner.buffer.is_none() {
|
if inner.buffer.is_none() {
|
||||||
resource.post_error(
|
resource.post_error(
|
||||||
zcosmic_screencopy_frame_v2::Error::NoBuffer,
|
ext_image_copy_capture_frame_v1::Error::NoBuffer,
|
||||||
"Attempting to capture frame without a buffer",
|
"Attempting to capture frame without a buffer",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -1031,7 +1035,7 @@ where
|
||||||
fn destroyed(
|
fn destroyed(
|
||||||
state: &mut D,
|
state: &mut D,
|
||||||
_client: wayland_backend::server::ClientId,
|
_client: wayland_backend::server::ClientId,
|
||||||
resource: &ZcosmicScreencopyFrameV2,
|
resource: &ExtImageCopyCaptureFrameV1,
|
||||||
data: &FrameData,
|
data: &FrameData,
|
||||||
) {
|
) {
|
||||||
{
|
{
|
||||||
|
|
@ -1064,22 +1068,22 @@ where
|
||||||
macro_rules! delegate_screencopy {
|
macro_rules! delegate_screencopy {
|
||||||
($(@<$( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+>)? $ty: ty) => {
|
($(@<$( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+>)? $ty: ty) => {
|
||||||
smithay::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
smithay::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
||||||
cosmic_protocols::screencopy::v2::server::zcosmic_screencopy_manager_v2::ZcosmicScreencopyManagerV2: $crate::wayland::protocols::screencopy::ScreencopyGlobalData
|
smithay::reexports::wayland_protocols::ext::image_copy_capture::v1::server::ext_image_copy_capture_manager_v1::ExtImageCopyCaptureManagerV1: $crate::wayland::protocols::screencopy::ScreencopyGlobalData
|
||||||
] => $crate::wayland::protocols::screencopy::ScreencopyState);
|
] => $crate::wayland::protocols::screencopy::ScreencopyState);
|
||||||
smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
||||||
cosmic_protocols::screencopy::v2::server::zcosmic_screencopy_manager_v2::ZcosmicScreencopyManagerV2: $crate::wayland::protocols::screencopy::ScreencopyData
|
smithay::reexports::wayland_protocols::ext::image_copy_capture::v1::server::ext_image_copy_capture_manager_v1::ExtImageCopyCaptureManagerV1: $crate::wayland::protocols::screencopy::ScreencopyData
|
||||||
] => $crate::wayland::protocols::screencopy::ScreencopyState);
|
] => $crate::wayland::protocols::screencopy::ScreencopyState);
|
||||||
smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
||||||
cosmic_protocols::screencopy::v2::server::zcosmic_screencopy_session_v2::ZcosmicScreencopySessionV2: $crate::wayland::protocols::screencopy::SessionData
|
smithay::reexports::wayland_protocols::ext::image_copy_capture::v1::server::ext_image_copy_capture_session_v1::ExtImageCopyCaptureSessionV1: $crate::wayland::protocols::screencopy::SessionData
|
||||||
] => $crate::wayland::protocols::screencopy::ScreencopyState);
|
] => $crate::wayland::protocols::screencopy::ScreencopyState);
|
||||||
smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
||||||
cosmic_protocols::screencopy::v2::server::zcosmic_screencopy_cursor_session_v2::ZcosmicScreencopyCursorSessionV2: $crate::wayland::protocols::screencopy::CursorSessionData
|
smithay::reexports::wayland_protocols::ext::image_copy_capture::v1::server::ext_image_copy_capture_cursor_session_v1::ExtImageCopyCaptureCursorSessionV1: $crate::wayland::protocols::screencopy::CursorSessionData
|
||||||
] => $crate::wayland::protocols::screencopy::ScreencopyState);
|
] => $crate::wayland::protocols::screencopy::ScreencopyState);
|
||||||
smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
||||||
cosmic_protocols::screencopy::v2::server::zcosmic_screencopy_session_v2::ZcosmicScreencopySessionV2: $crate::wayland::protocols::screencopy::CursorSessionData
|
smithay::reexports::wayland_protocols::ext::image_copy_capture::v1::server::ext_image_copy_capture_session_v1::ExtImageCopyCaptureSessionV1: $crate::wayland::protocols::screencopy::CursorSessionData
|
||||||
] => $crate::wayland::protocols::screencopy::ScreencopyState);
|
] => $crate::wayland::protocols::screencopy::ScreencopyState);
|
||||||
smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
||||||
cosmic_protocols::screencopy::v2::server::zcosmic_screencopy_frame_v2::ZcosmicScreencopyFrameV2: $crate::wayland::protocols::screencopy::FrameData
|
smithay::reexports::wayland_protocols::ext::image_copy_capture::v1::server::ext_image_copy_capture_frame_v1::ExtImageCopyCaptureFrameV1: $crate::wayland::protocols::screencopy::FrameData
|
||||||
] => $crate::wayland::protocols::screencopy::ScreencopyState);
|
] => $crate::wayland::protocols::screencopy::ScreencopyState);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,13 @@ use std::{collections::HashSet, sync::Mutex};
|
||||||
|
|
||||||
use smithay::{
|
use smithay::{
|
||||||
output::Output,
|
output::Output,
|
||||||
reexports::wayland_server::{
|
reexports::{
|
||||||
backend::{ClientId, GlobalId},
|
wayland_protocols::ext::foreign_toplevel_list::v1::server::ext_foreign_toplevel_handle_v1::ExtForeignToplevelHandleV1,
|
||||||
protocol::{wl_output::WlOutput, wl_surface::WlSurface},
|
wayland_server::{
|
||||||
Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, Weak,
|
backend::{ClientId, GlobalId},
|
||||||
|
protocol::{wl_output::WlOutput, wl_surface::WlSurface},
|
||||||
|
Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, Weak,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
utils::{user_data::UserDataMap, IsAlive, Logical, Rectangle},
|
utils::{user_data::UserDataMap, IsAlive, Logical, Rectangle},
|
||||||
wayland::foreign_toplevel_list::{
|
wayland::foreign_toplevel_list::{
|
||||||
|
|
@ -633,6 +636,26 @@ pub fn window_from_handle<W: Window + 'static>(handle: ZcosmicToplevelHandleV1)
|
||||||
.and_then(|state| state.lock().unwrap().window.clone())
|
.and_then(|state| state.lock().unwrap().window.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn window_from_ext_handle<'a, W: Window + 'static, D>(
|
||||||
|
state: &'a D,
|
||||||
|
foreign_toplevel: &ExtForeignToplevelHandleV1,
|
||||||
|
) -> Option<&'a W>
|
||||||
|
where
|
||||||
|
D: ToplevelInfoHandler<Window = W>,
|
||||||
|
{
|
||||||
|
let handle = ForeignToplevelHandle::from_resource(foreign_toplevel)?;
|
||||||
|
state.toplevel_info_state().toplevels.iter().find(|w| {
|
||||||
|
w.user_data().get::<ToplevelState>().and_then(|inner| {
|
||||||
|
inner
|
||||||
|
.lock()
|
||||||
|
.unwrap()
|
||||||
|
.foreign_handle
|
||||||
|
.as_ref()
|
||||||
|
.map(|handle| handle.identifier())
|
||||||
|
}) == Some(handle.identifier())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! delegate_toplevel_info {
|
macro_rules! delegate_toplevel_info {
|
||||||
($(@<$( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+>)? $ty: ty, $window: ty) => {
|
($(@<$( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+>)? $ty: ty, $window: ty) => {
|
||||||
smithay::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
smithay::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue