diff --git a/examples/helpers/shell.rs b/examples/helpers/shell.rs index de73b2c..ddee1d1 100644 --- a/examples/helpers/shell.rs +++ b/examples/helpers/shell.rs @@ -67,16 +67,7 @@ impl wl_shell::Handler for WlShellStubHandler } } -unsafe impl ::wayland_server::Handler for WlShellStubHandler - where U: Send + 'static, - H: CompositorHandler + Send + 'static -{ - unsafe fn message(&mut self, evq: &mut EventLoopHandle, client: &Client, resource: &wl_shell::WlShell, - opcode: u32, args: *const ::wayland_server::sys::wl_argument) - -> Result<(), ()> { - as ::wayland_server::protocol::wl_shell::Handler>::__message(self, evq, client, resource, opcode, args) - } -} +server_declare_handler!(WlShellStubHandler, Send]>, wl_shell::Handler, wl_shell::WlShell); impl wl_shell_surface::Handler for WlShellStubHandler where U: Send + 'static, @@ -84,14 +75,4 @@ impl wl_shell_surface::Handler for WlShellStubHandler { } -unsafe impl ::wayland_server::Handler for WlShellStubHandler - where U: Send + 'static, - H: CompositorHandler + Send + 'static -{ - unsafe fn message(&mut self, evq: &mut EventLoopHandle, client: &Client, - resource: &wl_shell_surface::WlShellSurface, opcode: u32, - args: *const ::wayland_server::sys::wl_argument) - -> Result<(), ()> { - as ::wayland_server::protocol::wl_shell_surface::Handler>::__message(self, evq, client, resource, opcode, args) - } -} +server_declare_handler!(WlShellStubHandler, Send]>, wl_shell_surface::Handler, wl_shell_surface::WlShellSurface); diff --git a/examples/simple.rs b/examples/simple.rs index 5c76fc0..eca2509 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -1,3 +1,4 @@ +#[macro_use(server_declare_handler)] extern crate wayland_server; extern crate smithay; #[macro_use] diff --git a/src/compositor/handlers.rs b/src/compositor/handlers.rs index 03ff52b..4a6e598 100644 --- a/src/compositor/handlers.rs +++ b/src/compositor/handlers.rs @@ -32,17 +32,7 @@ impl wl_compositor::Handler for CompositorHandler } } -unsafe impl ::wayland_server::Handler for CompositorHandler - where U: Default + Send + 'static, - H: UserHandler + Send + 'static -{ - unsafe fn message(&mut self, evq: &mut EventLoopHandle, client: &Client, - resource: &wl_compositor::WlCompositor, opcode: u32, - args: *const ::wayland_server::sys::wl_argument) - -> Result<(), ()> { - as ::wayland_server::protocol::wl_compositor::Handler>::__message(self, evq, client, resource, opcode, args) - } -} +server_declare_handler!(CompositorHandler, Send]>, wl_compositor::Handler, wl_compositor::WlCompositor); /* * wl_surface @@ -130,15 +120,7 @@ impl> wl_surface::Handler for CompositorHandler { } } -unsafe impl> ::wayland_server::Handler - for CompositorHandler { - unsafe fn message(&mut self, evq: &mut EventLoopHandle, client: &Client, - resource: &wl_surface::WlSurface, opcode: u32, - args: *const ::wayland_server::sys::wl_argument) - -> Result<(), ()> { - as ::wayland_server::protocol::wl_surface::Handler>::__message(self, evq, client, resource, opcode, args) - } -} +server_declare_handler!(CompositorHandler]>, wl_surface::Handler, wl_surface::WlSurface); impl Destroy for CompositorDestructor { fn destroy(surface: &wl_surface::WlSurface) { @@ -181,14 +163,7 @@ impl wl_region::Handler for CompositorHandler { } } -unsafe impl ::wayland_server::Handler for CompositorHandler { - unsafe fn message(&mut self, evq: &mut EventLoopHandle, client: &Client, - resource: &wl_region::WlRegion, opcode: u32, - args: *const ::wayland_server::sys::wl_argument) - -> Result<(), ()> { - as ::wayland_server::protocol::wl_region::Handler>::__message(self, evq, client, resource, opcode, args) - } -} +server_declare_handler!(CompositorHandler, wl_region::Handler, wl_region::WlRegion); impl Destroy for CompositorDestructor { fn destroy(region: &wl_region::WlRegion) { @@ -222,17 +197,7 @@ impl wl_subcompositor::Handler for CompositorHandler } } -unsafe impl ::wayland_server::Handler for CompositorHandler - where U: Send + 'static, - H: Send + 'static -{ - unsafe fn message(&mut self, evq: &mut EventLoopHandle, client: &Client, - resource: &wl_subcompositor::WlSubcompositor, opcode: u32, - args: *const ::wayland_server::sys::wl_argument) - -> Result<(), ()> { - as ::wayland_server::protocol::wl_subcompositor::Handler>::__message(self, evq, client, resource, opcode, args) - } -} +server_declare_handler!(CompositorHandler, wl_subcompositor::Handler, wl_subcompositor::WlSubcompositor); /* * wl_subsurface @@ -293,14 +258,7 @@ impl wl_subsurface::Handler for CompositorHandler { } } -unsafe impl ::wayland_server::Handler for CompositorHandler { - unsafe fn message(&mut self, evq: &mut EventLoopHandle, client: &Client, - resource: &wl_subsurface::WlSubsurface, opcode: u32, - args: *const ::wayland_server::sys::wl_argument) - -> Result<(), ()> { - as ::wayland_server::protocol::wl_subsurface::Handler>::__message(self, evq, client, resource, opcode, args) - } -} +server_declare_handler!(CompositorHandler, wl_subsurface::Handler, wl_subsurface::WlSubsurface); impl Destroy for CompositorDestructor { fn destroy(subsurface: &wl_subsurface::WlSubsurface) {