Skip to content
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ The following methods are no longer needed as Smithay does them automatically no

You also no longer need to manually set `LayerSurfaceAttributes::initial_configure_sent`, Smithay handles it automatically.

The `delegate_*!` macros have been replaced with a single `delegate_dispatch2!` macro, which implements dispatch in terms
of new `Dipsatch2` and `GlobalDispatch2` traits. These will replace `Dispatch` and `GlobalDispatch` in a future version of
`wayland_server`.

### Additions

- ExtBackgroundEffect protocol is now available in `smithay::wayland::background_effect` module.
Expand Down
61 changes: 3 additions & 58 deletions anvil/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,7 @@ use smithay::{
RenderElementStates, default_primary_scanout_output_compare, utils::select_dmabuf_feedback,
},
},
delegate_compositor, delegate_data_control, delegate_data_device, delegate_fixes,
delegate_fractional_scale, delegate_input_method_manager, delegate_keyboard_shortcuts_inhibit,
delegate_layer_shell, delegate_output, delegate_pointer_constraints, delegate_pointer_gestures,
delegate_presentation, delegate_primary_selection, delegate_relative_pointer, delegate_seat,
delegate_security_context, delegate_shm, delegate_tablet_manager, delegate_text_input_manager,
delegate_viewporter, delegate_virtual_keyboard_manager, delegate_xdg_activation, delegate_xdg_decoration,
delegate_xdg_shell,
delegate_dispatch2,
desktop::{
PopupKind, PopupManager, Space,
space::SpaceElement,
Expand Down Expand Up @@ -112,7 +106,6 @@ use crate::{
};
#[cfg(feature = "xwayland")]
use smithay::{
delegate_xwayland_keyboard_grab, delegate_xwayland_shell,
utils::Size,
wayland::selection::{SelectionSource, SelectionTarget},
wayland::xwayland_keyboard_grab::{XWaylandKeyboardGrabHandler, XWaylandKeyboardGrabState},
Expand Down Expand Up @@ -197,8 +190,6 @@ pub struct DndIcon {
pub offset: Point<i32, Logical>,
}

delegate_compositor!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

impl<BackendData: Backend> DataDeviceHandler for AnvilState<BackendData> {
fn data_device_state(&mut self) -> &mut DataDeviceState {
&mut self.data_device_state
Expand Down Expand Up @@ -254,10 +245,8 @@ impl<BackendData: Backend> DndGrabHandler for AnvilState<BackendData> {
self.dnd_icon = None;
}
}
delegate_data_device!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

impl<BackendData: Backend> OutputHandler for AnvilState<BackendData> {}
delegate_output!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

impl<BackendData: Backend> SelectionHandler for AnvilState<BackendData> {
type SelectionUserData = ();
Expand Down Expand Up @@ -293,22 +282,18 @@ impl<BackendData: Backend> PrimarySelectionHandler for AnvilState<BackendData> {
&mut self.primary_selection_state
}
}
delegate_primary_selection!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

impl<BackendData: Backend> DataControlHandler for AnvilState<BackendData> {
fn data_control_state(&mut self) -> &mut DataControlState {
&mut self.data_control_state
}
}

delegate_data_control!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

impl<BackendData: Backend> ShmHandler for AnvilState<BackendData> {
fn shm_state(&self) -> &ShmState {
&self.shm_state
}
}
delegate_shm!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

impl<BackendData: Backend> SeatHandler for AnvilState<BackendData> {
type KeyboardFocus = KeyboardFocusTarget;
Expand Down Expand Up @@ -336,17 +321,13 @@ impl<BackendData: Backend> SeatHandler for AnvilState<BackendData> {
self.backend_data.update_led_state(led_state)
}
}
delegate_seat!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

impl<BackendData: Backend> TabletSeatHandler for AnvilState<BackendData> {
fn tablet_tool_image(&mut self, _tool: &TabletToolDescriptor, image: CursorImageStatus) {
// TODO: tablet tools should have their own cursors
self.cursor_status = image;
}
}
delegate_tablet_manager!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

delegate_text_input_manager!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

impl<BackendData: Backend> InputMethodHandler for AnvilState<BackendData> {
fn new_popup(&mut self, surface: PopupSurface) {
Expand All @@ -371,8 +352,6 @@ impl<BackendData: Backend> InputMethodHandler for AnvilState<BackendData> {
}
}

delegate_input_method_manager!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

impl<BackendData: Backend> KeyboardShortcutsInhibitHandler for AnvilState<BackendData> {
fn keyboard_shortcuts_inhibit_state(&mut self) -> &mut KeyboardShortcutsInhibitState {
&mut self.keyboard_shortcuts_inhibit_state
Expand All @@ -384,14 +363,6 @@ impl<BackendData: Backend> KeyboardShortcutsInhibitHandler for AnvilState<Backen
}
}

delegate_keyboard_shortcuts_inhibit!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

delegate_virtual_keyboard_manager!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

delegate_pointer_gestures!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

delegate_relative_pointer!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

impl<BackendData: Backend> PointerConstraintsHandler for AnvilState<BackendData> {
fn new_constraint(&mut self, surface: &WlSurface, pointer: &PointerHandle<Self>) {
// XXX region
Expand Down Expand Up @@ -428,9 +399,6 @@ impl<BackendData: Backend> PointerConstraintsHandler for AnvilState<BackendData>
}
}
}
delegate_pointer_constraints!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

delegate_viewporter!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

impl<BackendData: Backend> XdgActivationHandler for AnvilState<BackendData> {
fn activation_state(&mut self) -> &mut XdgActivationState {
Expand Down Expand Up @@ -469,7 +437,6 @@ impl<BackendData: Backend> XdgActivationHandler for AnvilState<BackendData> {
}
}
}
delegate_xdg_activation!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

impl<BackendData: Backend> XdgDecorationHandler for AnvilState<BackendData> {
fn new_decoration(&mut self, toplevel: ToplevelSurface) {
Expand Down Expand Up @@ -504,11 +471,6 @@ impl<BackendData: Backend> XdgDecorationHandler for AnvilState<BackendData> {
}
}
}
delegate_xdg_decoration!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

delegate_xdg_shell!(@<BackendData: Backend + 'static> AnvilState<BackendData>);
delegate_layer_shell!(@<BackendData: Backend + 'static> AnvilState<BackendData>);
delegate_presentation!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

impl<BackendData: Backend> FractionalScaleHandler for AnvilState<BackendData> {
fn new_fractional_scale(
Expand Down Expand Up @@ -557,7 +519,6 @@ impl<BackendData: Backend> FractionalScaleHandler for AnvilState<BackendData> {
});
}
}
delegate_fractional_scale!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

impl<BackendData: Backend + 'static> SecurityContextHandler for AnvilState<BackendData> {
fn context_created(&mut self, source: SecurityContextListenerSource, security_context: SecurityContext) {
Expand All @@ -577,7 +538,6 @@ impl<BackendData: Backend + 'static> SecurityContextHandler for AnvilState<Backe
.expect("Failed to init wayland socket source");
}
}
delegate_security_context!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

#[cfg(feature = "xwayland")]
impl<BackendData: Backend + 'static> XWaylandKeyboardGrabHandler for AnvilState<BackendData> {
Expand All @@ -589,33 +549,18 @@ impl<BackendData: Backend + 'static> XWaylandKeyboardGrabHandler for AnvilState<
Some(KeyboardFocusTarget::Window(elem.0.clone()))
}
}
#[cfg(feature = "xwayland")]
delegate_xwayland_keyboard_grab!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

#[cfg(feature = "xwayland")]
delegate_xwayland_shell!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

impl<BackendData: Backend> XdgForeignHandler for AnvilState<BackendData> {
fn xdg_foreign_state(&mut self) -> &mut XdgForeignState {
&mut self.xdg_foreign_state
}
}
smithay::delegate_xdg_foreign!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

smithay::delegate_single_pixel_buffer!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

smithay::delegate_fifo!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

smithay::delegate_commit_timing!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

delegate_fixes!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

impl<BackendData: Backend> ImageCaptureSourceHandler for AnvilState<BackendData> {
fn source_destroyed(&mut self, _source: ImageCaptureSource) {
// Anvil doesn't track sources
}
}
smithay::delegate_image_capture_source!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

impl<BackendData: Backend> OutputCaptureSourceHandler for AnvilState<BackendData> {
fn output_capture_source_state(&mut self) -> &mut OutputCaptureSourceState {
Expand All @@ -626,7 +571,6 @@ impl<BackendData: Backend> OutputCaptureSourceHandler for AnvilState<BackendData
source.user_data().insert_if_missing(|| output.downgrade());
}
}
smithay::delegate_output_capture_source!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

impl<BackendData: Backend> ImageCopyCaptureHandler for AnvilState<BackendData> {
fn image_copy_capture_state(&mut self) -> &mut ImageCopyCaptureState {
Expand Down Expand Up @@ -662,7 +606,8 @@ impl<BackendData: Backend> ImageCopyCaptureHandler for AnvilState<BackendData> {
frame.fail(smithay::wayland::image_copy_capture::CaptureFailureReason::Unknown);
}
}
smithay::delegate_image_copy_capture!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

delegate_dispatch2!(@<BackendData: Backend + 'static> AnvilState<BackendData>);

impl<BackendData: Backend + 'static> AnvilState<BackendData> {
pub fn init(
Expand Down
5 changes: 0 additions & 5 deletions anvil/src/udev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ use smithay::{
},
udev::{UdevBackend, UdevEvent, all_gpus, primary_gpu},
},
delegate_dmabuf, delegate_drm_lease,
desktop::{
space::{Space, SurfaceTree},
utils::OutputPresentationFeedback,
Expand Down Expand Up @@ -183,7 +182,6 @@ impl DmabufHandler for AnvilState<UdevData> {
}
}
}
delegate_dmabuf!(AnvilState<UdevData>);

impl Backend for UdevData {
const HAS_RELATIVE_MOTION: bool = true;
Expand Down Expand Up @@ -613,14 +611,11 @@ impl DrmLeaseHandler for AnvilState<UdevData> {
}
}

delegate_drm_lease!(AnvilState<UdevData>);

impl DrmSyncobjHandler for AnvilState<UdevData> {
fn drm_syncobj_state(&mut self) -> Option<&mut DrmSyncobjState> {
self.backend_data.syncobj_state.as_mut()
}
}
smithay::delegate_drm_syncobj!(AnvilState<UdevData>);

pub type RenderSurface = GbmBufferedSurface<GbmAllocator<DrmDeviceFd>, Option<OutputPresentationFeedback>>;

Expand Down
2 changes: 0 additions & 2 deletions anvil/src/winit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ use smithay::{
},
winit::{self, WinitEvent, WinitGraphicsBackend},
},
delegate_dmabuf,
input::{
keyboard::LedState,
pointer::{CursorImageAttributes, CursorImageStatus},
Expand Down Expand Up @@ -80,7 +79,6 @@ impl DmabufHandler for AnvilState<WinitData> {
}
}
}
delegate_dmabuf!(AnvilState<WinitData>);

impl Backend for WinitData {
fn seat_name(&self) -> String {
Expand Down
2 changes: 0 additions & 2 deletions anvil/src/x11.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ use smithay::{
vulkan::{Instance, PhysicalDevice, version::Version},
x11::{WindowBuilder, X11Backend, X11Event, X11Surface},
},
delegate_dmabuf,
input::{
keyboard::LedState,
pointer::{CursorImageAttributes, CursorImageStatus},
Expand Down Expand Up @@ -83,7 +82,6 @@ impl DmabufHandler for AnvilState<X11Data> {
}
}
}
delegate_dmabuf!(AnvilState<X11Data>);

impl Backend for X11Data {
fn seat_name(&self) -> String {
Expand Down
4 changes: 2 additions & 2 deletions examples/compositor.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::Arc;

use smithay::delegate_compositor;
use smithay::delegate_dispatch2;
use smithay::reexports::wayland_server::Display;

use smithay::wayland::compositor::{CompositorClientState, CompositorHandler, CompositorState};
Expand Down Expand Up @@ -75,4 +75,4 @@ impl AsMut<CompositorState> for App {
}
}

delegate_compositor!(App);
delegate_dispatch2!(App);
8 changes: 1 addition & 7 deletions examples/minimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use smithay::{
},
winit::{self, WinitEvent},
},
delegate_compositor, delegate_data_device, delegate_seat, delegate_shm, delegate_xdg_shell,
input::{Seat, SeatHandler, SeatState, keyboard::FilterResult},
reexports::wayland_server::{Display, protocol::wl_seat},
utils::{Rectangle, Serial, Transform},
Expand Down Expand Up @@ -290,9 +289,4 @@ impl ClientData for ClientState {
}
}

// Macros used to delegate protocol handling to types in the app state.
delegate_xdg_shell!(App);
delegate_compositor!(App);
delegate_shm!(App);
delegate_seat!(App);
delegate_data_device!(App);
smithay::delegate_dispatch2!(App);
4 changes: 1 addition & 3 deletions examples/seat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use smithay::reexports::wayland_server::{
protocol::wl_surface::WlSurface,
};
use smithay::wayland::compositor::{CompositorClientState, CompositorHandler, CompositorState};
use smithay::{delegate_compositor, delegate_seat};

struct App {
compositor_state: CompositorState,
Expand Down Expand Up @@ -104,5 +103,4 @@ impl CompositorHandler for App {
fn commit(&mut self, _surface: &WlSurface) {}
}

delegate_compositor!(App);
delegate_seat!(App);
smithay::delegate_dispatch2!(App);
4 changes: 0 additions & 4 deletions smallvil/src/handlers/compositor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use crate::{Smallvil, grabs::resize_grab, state::ClientState};
use smithay::{
backend::renderer::utils::on_commit_buffer_handler,
delegate_compositor, delegate_shm,
reexports::wayland_server::{
Client,
protocol::{wl_buffer, wl_surface::WlSurface},
Expand Down Expand Up @@ -56,6 +55,3 @@ impl ShmHandler for Smallvil {
&self.shm_state
}
}

delegate_compositor!(Smallvil);
delegate_shm!(Smallvil);
8 changes: 2 additions & 6 deletions smallvil/src/handlers/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ use smithay::wayland::selection::SelectionHandler;
use smithay::wayland::selection::data_device::{
DataDeviceHandler, DataDeviceState, WaylandDndGrabHandler, set_data_device_focus,
};
use smithay::{delegate_data_device, delegate_output, delegate_seat};

impl SeatHandler for Smallvil {
type KeyboardFocus = WlSurface;
Expand All @@ -38,8 +37,6 @@ impl SeatHandler for Smallvil {
}
}

delegate_seat!(Smallvil);

//
// Wl Data Device
//
Expand Down Expand Up @@ -81,11 +78,10 @@ impl WaylandDndGrabHandler for Smallvil {
}
}

delegate_data_device!(Smallvil);

//
// Wl Output & Xdg Output
//

impl OutputHandler for Smallvil {}
delegate_output!(Smallvil);

smithay::delegate_dispatch2!(Smallvil);
4 changes: 0 additions & 4 deletions smallvil/src/handlers/xdg_shell.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use smithay::{
delegate_xdg_shell,
desktop::{PopupKind, PopupManager, Space, Window, find_popup_root_surface, get_popup_toplevel_coords},
input::{
Seat,
Expand Down Expand Up @@ -123,9 +122,6 @@ impl XdgShellHandler for Smallvil {
}
}

// Xdg Shell
delegate_xdg_shell!(Smallvil);

fn check_grab(
seat: &Seat<Smallvil>,
surface: &WlSurface,
Expand Down
Loading
Loading