Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,12 @@ pollster = "0.3.0"
[[example]]
name = "wgpu"
required-features = ["system"]

[patch.crates-io]
wayland-client = { git = "https://github.com/smithay/wayland-rs" }
wayland-protocols = { git = "https://github.com/smithay/wayland-rs" }
wayland-protocols-wlr = { git = "https://github.com/smithay/wayland-rs" }
wayland-protocols-misc = { git = "https://github.com/smithay/wayland-rs" }
wayland-protocols-experimental = { git = "https://github.com/smithay/wayland-rs" }
wayland-cursor = { git = "https://github.com/smithay/wayland-rs" }
wayland-backend = { git = "https://github.com/smithay/wayland-rs" }
4 changes: 2 additions & 2 deletions src/activation.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use wayland_client::{
globals::{BindError, GlobalList},
protocol::{wl_seat, wl_surface},
Dispatch, Proxy, QueueHandle,

Check warning on line 4 in src/activation.rs

View workflow job for this annotation

GitHub Actions / test (stable)

unused import: `Dispatch`

Check warning on line 4 in src/activation.rs

View workflow job for this annotation

GitHub Actions / test (beta)

unused import: `Dispatch`
};
use wayland_protocols::xdg::activation::v1::client::{xdg_activation_token_v1, xdg_activation_v1};

Expand Down Expand Up @@ -55,7 +55,7 @@
qh: &QueueHandle<State>,
) -> Result<ActivationState, BindError>
where
State: Dispatch<xdg_activation_v1::XdgActivationV1, GlobalData, State> + 'static,
State: ActivationHandler + 'static,
{
let xdg_activation = globals.bind(qh, 1..=1, GlobalData)?;
Ok(ActivationState { xdg_activation })
Expand All @@ -73,7 +73,7 @@
pub fn request_token<D, U>(&self, qh: &QueueHandle<D>, request_data: RequestData<U>)
where
D: ActivationHandler<RequestUdata = U>,
D: Dispatch<xdg_activation_token_v1::XdgActivationTokenV1, RequestData<U>> + 'static,
D: 'static,
U: Send + Sync + 'static,
{
let token = self.xdg_activation.get_activation_token(qh, request_data);
Expand Down
14 changes: 3 additions & 11 deletions src/background_effect.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use wayland_client::{
globals::GlobalList, protocol::wl_surface, Connection, Dispatch, QueueHandle, WEnum,
globals::GlobalList, protocol::wl_surface, Connection, Dispatch, QueueHandle,

Check warning on line 2 in src/background_effect.rs

View workflow job for this annotation

GitHub Actions / test (stable)

unused import: `Dispatch`

Check warning on line 2 in src/background_effect.rs

View workflow job for this annotation

GitHub Actions / test (beta)

unused import: `Dispatch`
};
use wayland_protocols::ext::background_effect::v1::client::{
ext_background_effect_manager_v1, ext_background_effect_surface_v1,
Expand All @@ -16,8 +16,7 @@
impl BackgroundEffectState {
pub fn new<D>(globals: &GlobalList, qh: &QueueHandle<D>) -> Self
where
D: Dispatch<ext_background_effect_manager_v1::ExtBackgroundEffectManagerV1, GlobalData>
+ 'static,
D: BackgroundEffectHandler + 'static,
{
let manager = GlobalProxy::from(globals.bind(qh, 1..=1, GlobalData));
Self { manager, capabilities: None }
Expand All @@ -39,8 +38,7 @@
qh: &QueueHandle<D>,
) -> Result<ext_background_effect_surface_v1::ExtBackgroundEffectSurfaceV1, GlobalError>
where
D: Dispatch<ext_background_effect_surface_v1::ExtBackgroundEffectSurfaceV1, GlobalData>
+ 'static,
D: BackgroundEffectHandler + 'static,
{
Ok(self.manager.get()?.get_background_effect(surface, qh, GlobalData))
}
Expand Down Expand Up @@ -76,12 +74,6 @@
) {
match event {
ext_background_effect_manager_v1::Event::Capabilities { flags } => {
let flags = match flags {
WEnum::Value(value) => value,
WEnum::Unknown(value) => {
ext_background_effect_manager_v1::Capability::from_bits_retain(value)
}
};
data.background_effect_state().capabilities = Some(flags);
data.update_capabilities();
}
Expand Down
14 changes: 7 additions & 7 deletions src/compositor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
wl_callback, wl_compositor, wl_output, wl_region,
wl_surface::{self, WlSurface},
},
Connection, Dispatch, Proxy, QueueHandle, WEnum,
Connection, Dispatch, Proxy, QueueHandle,

Check warning on line 15 in src/compositor.rs

View workflow job for this annotation

GitHub Actions / test (stable)

unused import: `Dispatch`

Check warning on line 15 in src/compositor.rs

View workflow job for this annotation

GitHub Actions / test (beta)

unused import: `Dispatch`
};

use crate::{
Expand Down Expand Up @@ -95,7 +95,7 @@
qh: &QueueHandle<State>,
) -> Result<CompositorState, BindError>
where
State: Dispatch<wl_compositor::WlCompositor, GlobalData, State> + 'static,
State: CompositorHandler + 'static,
{
let wl_compositor = globals.bind(qh, 1..=Self::API_VERSION_MAX, GlobalData)?;
Ok(CompositorState { wl_compositor })
Expand All @@ -107,7 +107,7 @@

pub fn create_surface<D>(&self, qh: &QueueHandle<D>) -> wl_surface::WlSurface
where
D: Dispatch<wl_surface::WlSurface, SurfaceData<()>> + 'static,
D: CompositorHandler + OutputHandler + 'static,
{
self.create_surface_with_data(qh, None, 1, ())
}
Expand All @@ -120,7 +120,7 @@
data: U,
) -> wl_surface::WlSurface
where
D: Dispatch<wl_surface::WlSurface, SurfaceData<U>> + 'static,
D: CompositorHandler + OutputHandler + 'static,
U: Send + Sync + 'static,
{
let data = SurfaceData::new(parent_surface, scale_factor, data);
Expand Down Expand Up @@ -229,7 +229,7 @@
qh: &QueueHandle<D>,
) -> Result<Self, GlobalError>
where
D: Dispatch<wl_surface::WlSurface, SurfaceData<()>> + 'static,
D: CompositorHandler + OutputHandler + 'static,
{
Self::with_data(compositor, qh, None, 1, ())
}
Expand All @@ -245,7 +245,7 @@
data: U,
) -> Result<Self, GlobalError>
where
D: Dispatch<wl_surface::WlSurface, SurfaceData<U>> + 'static,
D: CompositorHandler + OutputHandler + 'static,
U: Send + Sync + 'static,
{
let data = SurfaceData::new(parent_surface, scale_factor, data);
Expand Down Expand Up @@ -306,7 +306,7 @@
}
wl_surface::Event::PreferredBufferTransform { transform } => {
// Only handle known values.
if let WEnum::Value(transform) = transform {
if transform.available_since().is_some_and(|v| v <= surface.version()) {
let old_transform = std::mem::replace(&mut inner.transform, transform);
drop(inner);
if old_transform != transform {
Expand Down
7 changes: 2 additions & 5 deletions src/data_device_manager/data_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
event_created_child,
protocol::{
wl_data_device::{self, WlDataDevice},
wl_data_offer::{self, WlDataOffer},

Check failure on line 15 in src/data_device_manager/data_device.rs

View workflow job for this annotation

GitHub Actions / lint

unused imports: `Dispatch` and `self`

Check warning on line 15 in src/data_device_manager/data_device.rs

View workflow job for this annotation

GitHub Actions / ci (beta)

unused imports: `Dispatch` and `self`

Check warning on line 15 in src/data_device_manager/data_device.rs

View workflow job for this annotation

GitHub Actions / ci (beta)

unused imports: `Dispatch` and `self`

Check warning on line 15 in src/data_device_manager/data_device.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused imports: `Dispatch` and `self`

Check warning on line 15 in src/data_device_manager/data_device.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused imports: `Dispatch` and `self`

Check warning on line 15 in src/data_device_manager/data_device.rs

View workflow job for this annotation

GitHub Actions / test (stable)

unused imports: `Dispatch` and `self`

Check warning on line 15 in src/data_device_manager/data_device.rs

View workflow job for this annotation

GitHub Actions / test (beta)

unused imports: `Dispatch` and `self`
wl_seat::WlSeat,
},
Connection, Dispatch, Proxy, QueueHandle,
Expand Down Expand Up @@ -105,13 +105,10 @@

impl<D> Dispatch2<wl_data_device::WlDataDevice, D> for DataDeviceData
where
D: Dispatch<wl_data_offer::WlDataOffer, DataOfferData>
+ DataDeviceHandler
+ DataOfferHandler
+ 'static,
D: DataDeviceHandler + DataOfferHandler + 'static,
{
event_created_child!(D, WlDataDevice, [
0 => (WlDataOffer, Default::default())
0 => (WlDataOffer, DataOfferData::default())
]);

fn event(
Expand Down
36 changes: 15 additions & 21 deletions src/data_device_manager/data_offer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ where
fn event(
&self,
state: &mut D,
_offer: &wl_data_offer::WlDataOffer,
offer: &wl_data_offer::WlDataOffer,
event: <wl_data_offer::WlDataOffer as wayland_client::Proxy>::Event,
conn: &wayland_client::Connection,
qh: &wayland_client::QueueHandle<D>,
Expand All @@ -377,33 +377,27 @@ where
self.push_mime_type(mime_type);
}
wl_data_offer::Event::SourceActions { source_actions } => {
match source_actions {
wayland_client::WEnum::Value(a) => {
self.set_source_action(a);
match &mut self.inner.lock().unwrap().offer {
DataDeviceOffer::Drag(o) => {
state.source_actions(conn, qh, o, a);
}
DataDeviceOffer::Selection(_) => {}
DataDeviceOffer::Undetermined(_) => {}
if source_actions.available_since().is_some_and(|v| v <= offer.version()) {
self.set_source_action(source_actions);
match &mut self.inner.lock().unwrap().offer {
DataDeviceOffer::Drag(o) => {
state.source_actions(conn, qh, o, source_actions);
}
DataDeviceOffer::Selection(_) => {}
DataDeviceOffer::Undetermined(_) => {}
}
wayland_client::WEnum::Unknown(_) => {} // Ignore
}
}
wl_data_offer::Event::Action { dnd_action } => {
match dnd_action {
wayland_client::WEnum::Value(a) => {
self.set_selected_action(a);
match &mut self.inner.lock().unwrap().offer {
DataDeviceOffer::Drag(o) => {
state.selected_action(conn, qh, o, a);
}
DataDeviceOffer::Selection(_) => {}
DataDeviceOffer::Undetermined(_) => {}
if dnd_action.available_since().is_some_and(|v| v <= offer.version()) {
self.set_selected_action(dnd_action);
match &mut self.inner.lock().unwrap().offer {
DataDeviceOffer::Drag(o) => {
state.selected_action(conn, qh, o, dnd_action);
}
DataDeviceOffer::Selection(_) => {}
DataDeviceOffer::Undetermined(_) => {}
}
wayland_client::WEnum::Unknown(_) => {} // Ignore
}
}
_ => unimplemented!(),
Expand Down
9 changes: 4 additions & 5 deletions src/data_device_manager/data_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::reexports::client::{
wl_data_source::{self, WlDataSource},
wl_surface::WlSurface,
},
Connection, Proxy, QueueHandle, WEnum,
Connection, Proxy, QueueHandle,
};

use super::{data_device::DataDevice, WritePipe};
Expand Down Expand Up @@ -103,12 +103,11 @@ where
wl_data_source::Event::DndFinished => {
state.dnd_finished(conn, qh, source);
}
wl_data_source::Event::Action { dnd_action } => match dnd_action {
WEnum::Value(dnd_action) => {
wl_data_source::Event::Action { dnd_action } => {
if dnd_action.available_since().is_some_and(|v| v <= source.version()) {
state.action(conn, qh, source, dnd_action);
}
WEnum::Unknown(_) => {}
},
}
_ => unimplemented!(),
};
}
Expand Down
17 changes: 9 additions & 8 deletions src/data_device_manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::reexports::client::{
globals::{BindError, GlobalList},
protocol::{
wl_data_device,

Check failure on line 7 in src/data_device_manager/mod.rs

View workflow job for this annotation

GitHub Actions / lint

unused imports: `Dispatch` and `wl_data_device`

Check warning on line 7 in src/data_device_manager/mod.rs

View workflow job for this annotation

GitHub Actions / ci (beta)

unused imports: `Dispatch` and `wl_data_device`

Check warning on line 7 in src/data_device_manager/mod.rs

View workflow job for this annotation

GitHub Actions / ci (beta)

unused imports: `Dispatch` and `wl_data_device`

Check warning on line 7 in src/data_device_manager/mod.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused imports: `Dispatch` and `wl_data_device`

Check warning on line 7 in src/data_device_manager/mod.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused imports: `Dispatch` and `wl_data_device`

Check warning on line 7 in src/data_device_manager/mod.rs

View workflow job for this annotation

GitHub Actions / test (stable)

unused imports: `Dispatch` and `wl_data_device`

Check warning on line 7 in src/data_device_manager/mod.rs

View workflow job for this annotation

GitHub Actions / test (beta)

unused imports: `Dispatch` and `wl_data_device`
wl_data_device_manager::{self, DndAction, WlDataDeviceManager},
wl_data_source::WlDataSource,
wl_seat::WlSeat,
Expand All @@ -21,8 +21,9 @@
pub use read_pipe::*;
pub use write_pipe::*;

use data_device::{DataDevice, DataDeviceData};
use data_source::{CopyPasteSource, DataSourceData, DragSource};
use data_device::{DataDevice, DataDeviceData, DataDeviceHandler};
use data_offer::DataOfferHandler;
use data_source::{CopyPasteSource, DataSourceData, DataSourceHandler, DragSource};

#[derive(Debug)]
pub struct DataDeviceManagerState {
Expand All @@ -32,7 +33,7 @@
impl DataDeviceManagerState {
pub fn bind<State>(globals: &GlobalList, qh: &QueueHandle<State>) -> Result<Self, BindError>
where
State: Dispatch<WlDataDeviceManager, GlobalData, State> + 'static,
State: 'static,
{
let manager = globals.bind(qh, 1..=3, GlobalData)?;
Ok(Self { manager })
Expand All @@ -49,7 +50,7 @@
mime_types: impl IntoIterator<Item = T>,
) -> CopyPasteSource
where
D: Dispatch<WlDataSource, DataSourceData<()>> + 'static,
D: DataSourceHandler + 'static,
{
CopyPasteSource { inner: self.create_data_source(qh, mime_types, None) }
}
Expand All @@ -62,7 +63,7 @@
dnd_actions: DndAction,
) -> DragSource
where
D: Dispatch<WlDataSource, DataSourceData<()>> + 'static,
D: DataSourceHandler + 'static,
{
DragSource { inner: self.create_data_source(qh, mime_types, Some(dnd_actions)) }
}
Expand All @@ -75,9 +76,9 @@
dnd_actions: Option<DndAction>,
) -> WlDataSource
where
D: Dispatch<WlDataSource, DataSourceData<()>> + 'static,
D: DataSourceHandler + 'static,
{
let source = self.manager.create_data_source(qh, Default::default());
let source = self.manager.create_data_source(qh, DataSourceData::new(()));

for mime in mime_types {
source.offer(mime.to_string());
Expand All @@ -95,7 +96,7 @@
/// create a new data device for a given seat
pub fn get_data_device<D>(&self, qh: &QueueHandle<D>, seat: &WlSeat) -> DataDevice
where
D: Dispatch<wl_data_device::WlDataDevice, DataDeviceData> + 'static,
D: DataDeviceHandler + DataOfferHandler + 'static,
{
let data = DataDeviceData::new(seat.clone());
DataDevice { device: self.manager.get_data_device(seat, qh, data) }
Expand Down
41 changes: 2 additions & 39 deletions src/dispatch2.rs
Original file line number Diff line number Diff line change
@@ -1,47 +1,10 @@
use std::sync::Arc;

Check failure on line 1 in src/dispatch2.rs

View workflow job for this annotation

GitHub Actions / lint

unused import: `std::sync::Arc`

Check warning on line 1 in src/dispatch2.rs

View workflow job for this annotation

GitHub Actions / ci (beta)

unused import: `std::sync::Arc`

Check warning on line 1 in src/dispatch2.rs

View workflow job for this annotation

GitHub Actions / ci (beta)

unused import: `std::sync::Arc`

Check warning on line 1 in src/dispatch2.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused import: `std::sync::Arc`

Check warning on line 1 in src/dispatch2.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused import: `std::sync::Arc`

Check warning on line 1 in src/dispatch2.rs

View workflow job for this annotation

GitHub Actions / test (stable)

unused import: `std::sync::Arc`

Check warning on line 1 in src/dispatch2.rs

View workflow job for this annotation

GitHub Actions / test (beta)

unused import: `std::sync::Arc`
use wayland_client::backend::ObjectData;

Check failure on line 2 in src/dispatch2.rs

View workflow job for this annotation

GitHub Actions / lint

unused import: `wayland_client::backend::ObjectData`

Check warning on line 2 in src/dispatch2.rs

View workflow job for this annotation

GitHub Actions / ci (beta)

unused import: `wayland_client::backend::ObjectData`

Check warning on line 2 in src/dispatch2.rs

View workflow job for this annotation

GitHub Actions / ci (beta)

unused import: `wayland_client::backend::ObjectData`

Check warning on line 2 in src/dispatch2.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused import: `wayland_client::backend::ObjectData`

Check warning on line 2 in src/dispatch2.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused import: `wayland_client::backend::ObjectData`

Check warning on line 2 in src/dispatch2.rs

View workflow job for this annotation

GitHub Actions / test (stable)

unused import: `wayland_client::backend::ObjectData`

Check warning on line 2 in src/dispatch2.rs

View workflow job for this annotation

GitHub Actions / test (beta)

unused import: `wayland_client::backend::ObjectData`
use wayland_client::{Connection, Proxy, QueueHandle};

Check failure on line 3 in src/dispatch2.rs

View workflow job for this annotation

GitHub Actions / lint

unused imports: `Connection`, `Proxy`, and `QueueHandle`

Check warning on line 3 in src/dispatch2.rs

View workflow job for this annotation

GitHub Actions / ci (beta)

unused imports: `Connection`, `Proxy`, and `QueueHandle`

Check warning on line 3 in src/dispatch2.rs

View workflow job for this annotation

GitHub Actions / ci (beta)

unused imports: `Connection`, `Proxy`, and `QueueHandle`

Check warning on line 3 in src/dispatch2.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused imports: `Connection`, `Proxy`, and `QueueHandle`

Check warning on line 3 in src/dispatch2.rs

View workflow job for this annotation

GitHub Actions / ci (stable)

unused imports: `Connection`, `Proxy`, and `QueueHandle`

Check warning on line 3 in src/dispatch2.rs

View workflow job for this annotation

GitHub Actions / test (stable)

unused imports: `Connection`, `Proxy`, and `QueueHandle`

Check warning on line 3 in src/dispatch2.rs

View workflow job for this annotation

GitHub Actions / test (beta)

unused imports: `Connection`, `Proxy`, and `QueueHandle`

pub trait Dispatch2<I: Proxy, State> {
fn event(
&self,
_: &mut State,
_: &I,
_: <I as Proxy>::Event,
_: &Connection,
_: &QueueHandle<State>,
);

fn event_created_child(opcode: u16, _qh: &QueueHandle<State>) -> Arc<dyn ObjectData> {
panic!(
"Missing event_created_child specialization for event opcode {} of {}",
opcode,
I::interface().name
);
}
}
pub use wayland_client::Dispatch as Dispatch2;

#[macro_export]
macro_rules! delegate_dispatch2 {
($(@<$( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+>)? $ty: ty) => {
impl<$( $( $lt $( : $clt $(+ $dlt )* )? ),+, )? I, UserData> $crate::reexports::client::Dispatch<I, UserData> for $ty
where
I: $crate::reexports::client::Proxy,
UserData: $crate::dispatch2::Dispatch2<I, $ty> {
fn event(
state: &mut $ty,
proxy: &I,
event: <I as $crate::reexports::client::Proxy>::Event,
data: &UserData,
conn: &$crate::reexports::client::Connection,
qh: &$crate::reexports::client::QueueHandle<$ty>,
) {
data.event(state, proxy, event, conn, qh);
}

fn event_created_child(opcode: u16, qh: &$crate::reexports::client::QueueHandle<$ty>) -> ::std::sync::Arc<dyn $crate::reexports::client::backend::ObjectData> {
UserData::event_created_child(opcode, qh)
}
}
};
($(@<$( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+>)? $ty: ty) => {};
}
Loading
Loading