Skip to content

Commit

Permalink
add debug information to xdgrdp backend
Browse files Browse the repository at this point in the history
  • Loading branch information
feschber committed Dec 17, 2023
1 parent ad2aeae commit 19143b9
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/backend/consumer/xdg_desktop_portal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use ashpd::{
};
use async_trait::async_trait;

use crate::consumer::EventConsumer;
use crate::{consumer::EventConsumer, event::{Event::{Keyboard, Pointer}, PointerEvent, KeyboardEvent}, client::ClientEvent};

pub struct DesktopPortalConsumer<'a> {
proxy: RemoteDesktop<'a>,
Expand All @@ -17,8 +17,11 @@ pub struct DesktopPortalConsumer<'a> {

impl<'a> DesktopPortalConsumer<'a> {
pub async fn new() -> Result<DesktopPortalConsumer<'a>> {
log::debug!("connecting to org.freedesktop.portal.RemoteDesktop portal ...");
let proxy = RemoteDesktop::new().await?;
log::debug!("creating session ...");
let session = proxy.create_session().await?;
log::debug!("selecting devices ...");
proxy
.select_devices(&session, DeviceType::Keyboard | DeviceType::Pointer)
.await?;
Expand All @@ -27,6 +30,7 @@ impl<'a> DesktopPortalConsumer<'a> {
.start(&session, &WindowIdentifier::default())
.await?
.response()?;
log::debug!("started session");

Ok(Self { proxy, session })
}
Expand All @@ -36,9 +40,9 @@ impl<'a> DesktopPortalConsumer<'a> {
impl<'a> EventConsumer for DesktopPortalConsumer<'a> {
async fn consume(&mut self, event: crate::event::Event, _client: crate::client::ClientHandle) {
match event {
crate::event::Event::Pointer(p) => {
Pointer(p) => {
match p {
crate::event::PointerEvent::Motion {
PointerEvent::Motion {
time: _,
relative_x,
relative_y,
Expand All @@ -51,7 +55,7 @@ impl<'a> EventConsumer for DesktopPortalConsumer<'a> {
log::warn!("{e}");
}
}
crate::event::PointerEvent::Button {
PointerEvent::Button {
time: _,
button,
state,
Expand All @@ -68,7 +72,7 @@ impl<'a> EventConsumer for DesktopPortalConsumer<'a> {
log::warn!("{e}");
}
}
crate::event::PointerEvent::Axis {
PointerEvent::Axis {
time: _,
axis,
value,
Expand All @@ -86,12 +90,12 @@ impl<'a> EventConsumer for DesktopPortalConsumer<'a> {
log::warn!("{e}");
}
}
crate::event::PointerEvent::Frame {} => {}
PointerEvent::Frame {} => {}
}
}
crate::event::Event::Keyboard(k) => {
Keyboard(k) => {
match k {
crate::event::KeyboardEvent::Key {
KeyboardEvent::Key {
time: _,
key,
state,
Expand All @@ -108,7 +112,7 @@ impl<'a> EventConsumer for DesktopPortalConsumer<'a> {
log::warn!("{e}");
}
}
crate::event::KeyboardEvent::Modifiers { .. } => {
KeyboardEvent::Modifiers { .. } => {
// ignore
}
}
Expand All @@ -117,7 +121,7 @@ impl<'a> EventConsumer for DesktopPortalConsumer<'a> {
}
}

async fn notify(&mut self, _client: crate::client::ClientEvent) {}
async fn notify(&mut self, _client: ClientEvent) {}

async fn destroy(&mut self) {
log::debug!("closing remote desktop session");
Expand Down

0 comments on commit 19143b9

Please sign in to comment.