Update Smithay to Dispatch2 refactor
Browse files at this commitd989e372497cebdf4e7e08f6b3a4a59d545ccc8bParent: d66c6ca16 changed files +177 -463
- Cargo.lock +2 -2
- Cargo.toml +2 -2
- src/handlers/background_effect.rs +0 -2
- src/handlers/compositor.rs +0 -4
- src/handlers/layer_shell.rs +0 -2
- src/handlers/mod.rs +0 -55
- src/handlers/xdg_shell.rs +0 -8
- src/niri.rs +2 -0
- src/protocols/ext_workspace.rs +35 -61
- src/protocols/foreign_toplevel.rs +40 -85
- src/protocols/gamma_control.rs +15 -41
- src/protocols/mod.rs +6 -0
- src/protocols/mutter_x11_interop.rs +9 -27
- src/protocols/output_management.rs +36 -97
- src/protocols/screencopy.rs +16 -41
- src/protocols/virtual_pointer.rs +14 -36
Cargo.lockmodified+2 -2
| @@ -3485,7 +3485,7 @@ checksum = "b7c388c1b5e93756d0c740965c41e8822f866621d41acbdf6336a6a168f8840c" | ||
| 3485 | 3485 | [[package]] |
| 3486 | 3486 | name = "smithay" |
| 3487 | 3487 | version = "0.7.0" |
| 3488 | -source = "git+https://github.com/Smithay/smithay.git?rev=ff5fa7df392cecfba049ffed55cdaa4e98a8e7ef#ff5fa7df392cecfba049ffed55cdaa4e98a8e7ef" | |
| 3488 | +source = "git+https://github.com/Smithay/smithay.git?rev=0d14cd655f6e905ad5110ff0384400da223f2cab#0d14cd655f6e905ad5110ff0384400da223f2cab" | |
| 3489 | 3489 | dependencies = [ |
| 3490 | 3490 | "aliasable", |
| 3491 | 3491 | "appendlist", |
| @@ -3560,7 +3560,7 @@ dependencies = [ | ||
| 3560 | 3560 | [[package]] |
| 3561 | 3561 | name = "smithay-drm-extras" |
| 3562 | 3562 | version = "0.1.0" |
| 3563 | -source = "git+https://github.com/Smithay/smithay.git?rev=ff5fa7df392cecfba049ffed55cdaa4e98a8e7ef#ff5fa7df392cecfba049ffed55cdaa4e98a8e7ef" | |
| 3563 | +source = "git+https://github.com/Smithay/smithay.git?rev=0d14cd655f6e905ad5110ff0384400da223f2cab#0d14cd655f6e905ad5110ff0384400da223f2cab" | |
| 3564 | 3564 | dependencies = [ |
| 3565 | 3565 | "drm", |
| 3566 | 3566 | "libdisplay-info", |
Cargo.tomlmodified+2 -2
| @@ -28,13 +28,13 @@ tracy-client = { version = "0.18.4", default-features = false } | ||
| 28 | 28 | [workspace.dependencies.smithay] |
| 29 | 29 | # version = "0.4.1" |
| 30 | 30 | git = "https://github.com/Smithay/smithay.git" |
| 31 | -rev = "ff5fa7df392cecfba049ffed55cdaa4e98a8e7ef" | |
| 31 | +rev = "0d14cd655f6e905ad5110ff0384400da223f2cab" | |
| 32 | 32 | default-features = false |
| 33 | 33 | |
| 34 | 34 | [workspace.dependencies.smithay-drm-extras] |
| 35 | 35 | # version = "0.1.0" |
| 36 | 36 | git = "https://github.com/Smithay/smithay.git" |
| 37 | -rev = "ff5fa7df392cecfba049ffed55cdaa4e98a8e7ef" | |
| 37 | +rev = "0d14cd655f6e905ad5110ff0384400da223f2cab" | |
| 38 | 38 | # path = "../smithay/smithay-drm-extras" |
| 39 | 39 | |
| 40 | 40 | [package] |
src/handlers/background_effect.rsmodified+0 -2
| @@ -1,6 +1,5 @@ | ||
| 1 | 1 | use std::sync::{Arc, Mutex}; |
| 2 | 2 | |
| 3 | -use smithay::delegate_background_effect; | |
| 4 | 3 | use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; |
| 5 | 4 | use smithay::utils::{Logical, Rectangle}; |
| 6 | 5 | use smithay::wayland::background_effect::{ |
| @@ -120,4 +119,3 @@ impl ExtBackgroundEffectHandler for State { | ||
| 120 | 119 | mark_blur_region_pending_dirty(&wl_surface); |
| 121 | 120 | } |
| 122 | 121 | } |
| 123 | -delegate_background_effect!(State); |
src/handlers/compositor.rsmodified+0 -4
| @@ -16,7 +16,6 @@ use smithay::wayland::compositor::{ | ||
| 16 | 16 | use smithay::wayland::dmabuf::get_dmabuf; |
| 17 | 17 | use smithay::wayland::shell::xdg::ToplevelCachedState; |
| 18 | 18 | use smithay::wayland::shm::{ShmHandler, ShmState}; |
| 19 | -use smithay::{delegate_compositor, delegate_shm}; | |
| 20 | 19 | |
| 21 | 20 | use super::xdg_shell::add_mapped_toplevel_pre_commit_hook; |
| 22 | 21 | use crate::handlers::XDG_ACTIVATION_TOKEN_TIMEOUT; |
| @@ -523,9 +522,6 @@ impl ShmHandler for State { | ||
| 523 | 522 | } |
| 524 | 523 | } |
| 525 | 524 | |
| 526 | -delegate_compositor!(State); | |
| 527 | -delegate_shm!(State); | |
| 528 | - | |
| 529 | 525 | impl State { |
| 530 | 526 | pub fn add_default_dmabuf_pre_commit_hook(&mut self, surface: &WlSurface) { |
| 531 | 527 | if !surface.is_alive() { |
src/handlers/layer_shell.rsmodified+0 -2
| @@ -1,4 +1,3 @@ | ||
| 1 | -use smithay::delegate_layer_shell; | |
| 2 | 1 | use smithay::desktop::{layer_map_for_output, LayerSurface, PopupKind, WindowSurfaceType}; |
| 3 | 2 | use smithay::reexports::wayland_server::protocol::wl_output::WlOutput; |
| 4 | 3 | use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; |
| @@ -73,7 +72,6 @@ impl WlrLayerShellHandler for State { | ||
| 73 | 72 | self.unconstrain_popup(&PopupKind::Xdg(popup)); |
| 74 | 73 | } |
| 75 | 74 | } |
| 76 | -delegate_layer_shell!(State); | |
| 77 | 75 | |
| 78 | 76 | impl State { |
| 79 | 77 | pub fn layer_shell_handle_commit(&mut self, surface: &WlSurface) -> bool { |
src/handlers/mod.rsmodified+0 -55
| @@ -61,16 +61,6 @@ use smithay::wayland::tablet_manager::TabletSeatHandler; | ||
| 61 | 61 | use smithay::wayland::xdg_activation::{ |
| 62 | 62 | XdgActivationHandler, XdgActivationState, XdgActivationToken, XdgActivationTokenData, |
| 63 | 63 | }; |
| 64 | -use smithay::{ | |
| 65 | - delegate_cursor_shape, delegate_data_control, delegate_data_device, delegate_dmabuf, | |
| 66 | - delegate_drm_lease, delegate_ext_data_control, delegate_fractional_scale, | |
| 67 | - delegate_idle_inhibit, delegate_idle_notify, delegate_input_method_manager, | |
| 68 | - delegate_keyboard_shortcuts_inhibit, delegate_output, delegate_pointer_constraints, | |
| 69 | - delegate_pointer_gestures, delegate_presentation, delegate_primary_selection, | |
| 70 | - delegate_relative_pointer, delegate_seat, delegate_security_context, delegate_session_lock, | |
| 71 | - delegate_single_pixel_buffer, delegate_tablet_manager, delegate_text_input_manager, | |
| 72 | - delegate_viewporter, delegate_virtual_keyboard_manager, delegate_xdg_activation, | |
| 73 | -}; | |
| 74 | 64 | |
| 75 | 65 | pub use crate::handlers::xdg_shell::KdeDecorationsModeState; |
| 76 | 66 | use crate::layout::workspace::WorkspaceId; |
| @@ -90,11 +80,6 @@ use crate::protocols::virtual_pointer::{ | ||
| 90 | 80 | VirtualPointerMotionEvent, |
| 91 | 81 | }; |
| 92 | 82 | use crate::utils::{output_size, send_scale_transform}; |
| 93 | -use crate::{ | |
| 94 | - delegate_ext_workspace, delegate_foreign_toplevel, delegate_gamma_control, | |
| 95 | - delegate_mutter_x11_interop, delegate_output_management, delegate_screencopy, | |
| 96 | - delegate_virtual_pointer, | |
| 97 | -}; | |
| 98 | 83 | |
| 99 | 84 | pub const XDG_ACTIVATION_TOKEN_TIMEOUT: Duration = Duration::from_secs(10); |
| 100 | 85 | |
| @@ -138,11 +123,6 @@ impl SeatHandler for State { | ||
| 138 | 123 | } |
| 139 | 124 | } |
| 140 | 125 | } |
| 141 | -delegate_seat!(State); | |
| 142 | -delegate_cursor_shape!(State); | |
| 143 | -delegate_pointer_gestures!(State); | |
| 144 | -delegate_relative_pointer!(State); | |
| 145 | -delegate_text_input_manager!(State); | |
| 146 | 126 | |
| 147 | 127 | impl TabletSeatHandler for State { |
| 148 | 128 | fn tablet_tool_image(&mut self, _tool: &TabletToolDescriptor, image: CursorImageStatus) { |
| @@ -152,7 +132,6 @@ impl TabletSeatHandler for State { | ||
| 152 | 132 | self.niri.queue_redraw_all(); |
| 153 | 133 | } |
| 154 | 134 | } |
| 155 | -delegate_tablet_manager!(State); | |
| 156 | 135 | |
| 157 | 136 | impl PointerConstraintsHandler for State { |
| 158 | 137 | fn new_constraint(&mut self, _surface: &WlSurface, _pointer: &PointerHandle<Self>) { |
| @@ -217,7 +196,6 @@ impl PointerConstraintsHandler for State { | ||
| 217 | 196 | } |
| 218 | 197 | } |
| 219 | 198 | } |
| 220 | -delegate_pointer_constraints!(State); | |
| 221 | 199 | |
| 222 | 200 | impl InputMethodHandler for State { |
| 223 | 201 | fn new_popup(&mut self, surface: PopupSurface) { |
| @@ -278,10 +256,6 @@ impl KeyboardShortcutsInhibitHandler for State { | ||
| 278 | 256 | } |
| 279 | 257 | } |
| 280 | 258 | |
| 281 | -delegate_input_method_manager!(State); | |
| 282 | -delegate_keyboard_shortcuts_inhibit!(State); | |
| 283 | -delegate_virtual_keyboard_manager!(State); | |
| 284 | - | |
| 285 | 259 | impl SelectionHandler for State { |
| 286 | 260 | type SelectionUserData = Arc<[u8]>; |
| 287 | 261 | |
| @@ -401,14 +375,11 @@ impl crate::niri::Niri { | ||
| 401 | 375 | } |
| 402 | 376 | } |
| 403 | 377 | |
| 404 | -delegate_data_device!(State); | |
| 405 | - | |
| 406 | 378 | impl PrimarySelectionHandler for State { |
| 407 | 379 | fn primary_selection_state(&mut self) -> &mut PrimarySelectionState { |
| 408 | 380 | &mut self.niri.primary_selection_state |
| 409 | 381 | } |
| 410 | 382 | } |
| 411 | -delegate_primary_selection!(State); | |
| 412 | 383 | |
| 413 | 384 | impl WlrDataControlHandler for State { |
| 414 | 385 | fn data_control_state(&mut self) -> &mut WlrDataControlState { |
| @@ -416,25 +387,18 @@ impl WlrDataControlHandler for State { | ||
| 416 | 387 | } |
| 417 | 388 | } |
| 418 | 389 | |
| 419 | -delegate_data_control!(State); | |
| 420 | - | |
| 421 | 390 | impl ExtDataControlHandler for State { |
| 422 | 391 | fn data_control_state(&mut self) -> &mut ExtDataControlState { |
| 423 | 392 | &mut self.niri.ext_data_control_state |
| 424 | 393 | } |
| 425 | 394 | } |
| 426 | 395 | |
| 427 | -delegate_ext_data_control!(State); | |
| 428 | - | |
| 429 | 396 | impl OutputHandler for State { |
| 430 | 397 | fn output_bound(&mut self, output: Output, wl_output: WlOutput) { |
| 431 | 398 | foreign_toplevel::on_output_bound(self, &output, &wl_output); |
| 432 | 399 | ext_workspace::on_output_bound(self, &output, &wl_output); |
| 433 | 400 | } |
| 434 | 401 | } |
| 435 | -delegate_output!(State); | |
| 436 | - | |
| 437 | -delegate_presentation!(State); | |
| 438 | 402 | |
| 439 | 403 | impl DmabufHandler for State { |
| 440 | 404 | fn dmabuf_state(&mut self) -> &mut DmabufState { |
| @@ -454,7 +418,6 @@ impl DmabufHandler for State { | ||
| 454 | 418 | } |
| 455 | 419 | } |
| 456 | 420 | } |
| 457 | -delegate_dmabuf!(State); | |
| 458 | 421 | |
| 459 | 422 | impl SessionLockHandler for State { |
| 460 | 423 | fn lock_state(&mut self) -> &mut SessionLockManagerState { |
| @@ -481,7 +444,6 @@ impl SessionLockHandler for State { | ||
| 481 | 444 | self.niri.new_lock_surface(surface, &output); |
| 482 | 445 | } |
| 483 | 446 | } |
| 484 | -delegate_session_lock!(State); | |
| 485 | 447 | |
| 486 | 448 | pub fn configure_lock_surface(surface: &LockSurface, output: &Output) { |
| 487 | 449 | surface.with_pending_state(|states| { |
| @@ -512,14 +474,12 @@ impl SecurityContextHandler for State { | ||
| 512 | 474 | .unwrap(); |
| 513 | 475 | } |
| 514 | 476 | } |
| 515 | -delegate_security_context!(State); | |
| 516 | 477 | |
| 517 | 478 | impl IdleNotifierHandler for State { |
| 518 | 479 | fn idle_notifier_state(&mut self) -> &mut IdleNotifierState<Self> { |
| 519 | 480 | &mut self.niri.idle_notifier_state |
| 520 | 481 | } |
| 521 | 482 | } |
| 522 | -delegate_idle_notify!(State); | |
| 523 | 483 | |
| 524 | 484 | impl IdleInhibitHandler for State { |
| 525 | 485 | fn inhibit(&mut self, surface: WlSurface) { |
| @@ -530,7 +490,6 @@ impl IdleInhibitHandler for State { | ||
| 530 | 490 | self.niri.idle_inhibiting_surfaces.remove(&surface); |
| 531 | 491 | } |
| 532 | 492 | } |
| 533 | -delegate_idle_inhibit!(State); | |
| 534 | 493 | |
| 535 | 494 | impl ForeignToplevelHandler for State { |
| 536 | 495 | fn foreign_toplevel_manager_state(&mut self) -> &mut ForeignToplevelManagerState { |
| @@ -595,7 +554,6 @@ impl ForeignToplevelHandler for State { | ||
| 595 | 554 | } |
| 596 | 555 | } |
| 597 | 556 | } |
| 598 | -delegate_foreign_toplevel!(State); | |
| 599 | 557 | |
| 600 | 558 | impl ExtWorkspaceHandler for State { |
| 601 | 559 | fn ext_workspace_manager_state(&mut self) -> &mut ExtWorkspaceManagerState { |
| @@ -631,7 +589,6 @@ impl ExtWorkspaceHandler for State { | ||
| 631 | 589 | } |
| 632 | 590 | } |
| 633 | 591 | } |
| 634 | -delegate_ext_workspace!(State); | |
| 635 | 592 | |
| 636 | 593 | impl ScreencopyHandler for State { |
| 637 | 594 | fn frame(&mut self, manager: &ZwlrScreencopyManagerV1, screencopy: Screencopy) { |
| @@ -661,7 +618,6 @@ impl ScreencopyHandler for State { | ||
| 661 | 618 | &mut self.niri.screencopy_state |
| 662 | 619 | } |
| 663 | 620 | } |
| 664 | -delegate_screencopy!(State); | |
| 665 | 621 | |
| 666 | 622 | impl VirtualPointerHandler for State { |
| 667 | 623 | fn virtual_pointer_manager_state(&mut self) -> &mut VirtualPointerManagerState { |
| @@ -686,7 +642,6 @@ impl VirtualPointerHandler for State { | ||
| 686 | 642 | self.process_input_event(InputEvent::<VirtualPointerInputBackend>::PointerAxis { event }); |
| 687 | 643 | } |
| 688 | 644 | } |
| 689 | -delegate_virtual_pointer!(State); | |
| 690 | 645 | |
| 691 | 646 | impl DrmLeaseHandler for State { |
| 692 | 647 | fn drm_lease_state(&mut self, node: DrmNode) -> &mut DrmLeaseState { |
| @@ -733,9 +688,6 @@ impl DrmLeaseHandler for State { | ||
| 733 | 688 | .remove_lease(lease_id); |
| 734 | 689 | } |
| 735 | 690 | } |
| 736 | -delegate_drm_lease!(State); | |
| 737 | - | |
| 738 | -delegate_viewporter!(State); | |
| 739 | 691 | |
| 740 | 692 | impl GammaControlHandler for State { |
| 741 | 693 | fn gamma_control_manager_state(&mut self) -> &mut GammaControlManagerState { |
| @@ -766,7 +718,6 @@ impl GammaControlHandler for State { | ||
| 766 | 718 | } |
| 767 | 719 | } |
| 768 | 720 | } |
| 769 | -delegate_gamma_control!(State); | |
| 770 | 721 | |
| 771 | 722 | struct UrgentOnlyMarker; |
| 772 | 723 | |
| @@ -840,10 +791,8 @@ impl XdgActivationHandler for State { | ||
| 840 | 791 | self.niri.activation_state.remove_token(&token); |
| 841 | 792 | } |
| 842 | 793 | } |
| 843 | -delegate_xdg_activation!(State); | |
| 844 | 794 | |
| 845 | 795 | impl FractionalScaleHandler for State {} |
| 846 | -delegate_fractional_scale!(State); | |
| 847 | 796 | |
| 848 | 797 | impl OutputManagementHandler for State { |
| 849 | 798 | fn output_management_state(&mut self) -> &mut OutputManagementManagerState { |
| @@ -855,9 +804,5 @@ impl OutputManagementHandler for State { | ||
| 855 | 804 | self.reload_output_config(); |
| 856 | 805 | } |
| 857 | 806 | } |
| 858 | -delegate_output_management!(State); | |
| 859 | 807 | |
| 860 | 808 | impl MutterX11InteropHandler for State {} |
| 861 | -delegate_mutter_x11_interop!(State); | |
| 862 | - | |
| 863 | -delegate_single_pixel_buffer!(State); |
src/handlers/xdg_shell.rsmodified+0 -8
| @@ -32,9 +32,6 @@ use smithay::wayland::shell::xdg::{ | ||
| 32 | 32 | XdgToplevelSurfaceData, |
| 33 | 33 | }; |
| 34 | 34 | use smithay::wayland::xdg_foreign::{XdgForeignHandler, XdgForeignState}; |
| 35 | -use smithay::{ | |
| 36 | - delegate_kde_decoration, delegate_xdg_decoration, delegate_xdg_foreign, delegate_xdg_shell, | |
| 37 | -}; | |
| 38 | 35 | use tracing::field::Empty; |
| 39 | 36 | |
| 40 | 37 | use crate::input::move_grab::MoveGrab; |
| @@ -918,8 +915,6 @@ impl XdgShellHandler for State { | ||
| 918 | 915 | } |
| 919 | 916 | } |
| 920 | 917 | |
| 921 | -delegate_xdg_shell!(State); | |
| 922 | - | |
| 923 | 918 | impl XdgDecorationHandler for State { |
| 924 | 919 | fn new_decoration(&mut self, toplevel: ToplevelSurface) { |
| 925 | 920 | // If we want CSD, we hide this global altogether. |
| @@ -973,7 +968,6 @@ impl XdgDecorationHandler for State { | ||
| 973 | 968 | } |
| 974 | 969 | } |
| 975 | 970 | } |
| 976 | -delegate_xdg_decoration!(State); | |
| 977 | 971 | |
| 978 | 972 | /// Whether KDE server decorations are in use. |
| 979 | 973 | #[derive(Default, Clone)] |
| @@ -1014,14 +1008,12 @@ impl KdeDecorationHandler for State { | ||
| 1014 | 1008 | }); |
| 1015 | 1009 | } |
| 1016 | 1010 | } |
| 1017 | -delegate_kde_decoration!(State); | |
| 1018 | 1011 | |
| 1019 | 1012 | impl XdgForeignHandler for State { |
| 1020 | 1013 | fn xdg_foreign_state(&mut self) -> &mut XdgForeignState { |
| 1021 | 1014 | &mut self.niri.xdg_foreign_state |
| 1022 | 1015 | } |
| 1023 | 1016 | } |
| 1024 | -delegate_xdg_foreign!(State); | |
| 1025 | 1017 | |
| 1026 | 1018 | impl State { |
| 1027 | 1019 | pub fn send_initial_configure(&mut self, toplevel: &ToplevelSurface) { |
src/niri.rsmodified+2 -0
| @@ -418,6 +418,8 @@ pub struct Niri { | ||
| 418 | 418 | pub casting: Screencasting, |
| 419 | 419 | } |
| 420 | 420 | |
| 421 | +smithay::delegate_dispatch2!(State); | |
| 422 | + | |
| 421 | 423 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
| 422 | 424 | pub enum PointerVisibility { |
| 423 | 425 | /// The pointer is visible. |
src/protocols/ext_workspace.rsmodified+35 -61
| @@ -26,11 +26,13 @@ use smithay::reexports::wayland_server::protocol::wl_output::WlOutput; | ||
| 26 | 26 | use smithay::reexports::wayland_server::{ |
| 27 | 27 | Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, |
| 28 | 28 | }; |
| 29 | +use smithay::wayland::{Dispatch2, GlobalDispatch2}; | |
| 29 | 30 | use wayland_backend::server::ClientId; |
| 30 | 31 | |
| 31 | 32 | use crate::layout::monitor::Monitor; |
| 32 | 33 | use crate::layout::workspace::{Workspace, WorkspaceId}; |
| 33 | 34 | use crate::niri::State; |
| 35 | +use crate::protocols::EmptyData; | |
| 34 | 36 | use crate::window::Mapped; |
| 35 | 37 | |
| 36 | 38 | const VERSION: u32 = 1; |
| @@ -67,6 +69,10 @@ struct ExtWorkspaceGroupData { | ||
| 67 | 69 | instances: Vec<ExtWorkspaceGroupHandleV1>, |
| 68 | 70 | } |
| 69 | 71 | |
| 72 | +// Wrapper struct for trait coherence. | |
| 73 | +#[derive(PartialEq, Eq)] | |
| 74 | +struct WrappedManager(ExtWorkspaceManagerV1); | |
| 75 | + | |
| 70 | 76 | struct ExtWorkspaceData { |
| 71 | 77 | // id cannot change once set. |
| 72 | 78 | id: Option<String>, |
| @@ -113,7 +119,7 @@ pub fn refresh(state: &mut State) { | ||
| 113 | 119 | |
| 114 | 120 | for group in &data.instances { |
| 115 | 121 | // Send workspace_leave for all workspaces in this group with matching manager. |
| 116 | - let manager: &ExtWorkspaceManagerV1 = group.data().unwrap(); | |
| 122 | + let manager: &WrappedManager = group.data().unwrap(); | |
| 117 | 123 | for ws in protocol_state.workspaces.values() { |
| 118 | 124 | if ws.output.as_ref() == Some(output) { |
| 119 | 125 | for workspace in &ws.instances { |
| @@ -199,7 +205,7 @@ fn refresh_workspace_group(protocol_state: &mut ExtWorkspaceManagerState, output | ||
| 199 | 205 | |
| 200 | 206 | // Send workspace_enter for all existing workspaces on this output. |
| 201 | 207 | for group in &data.instances { |
| 202 | - let manager: &ExtWorkspaceManagerV1 = group.data().unwrap(); | |
| 208 | + let manager: &WrappedManager = group.data().unwrap(); | |
| 203 | 209 | for ws in protocol_state.workspaces.values() { |
| 204 | 210 | if ws.output.as_ref() != Some(output) { |
| 205 | 211 | continue; |
| @@ -224,7 +230,7 @@ fn send_workspace_enter_leave( | ||
| 224 | 230 | if let Some(output) = &data.output { |
| 225 | 231 | if let Some(group_data) = workspace_groups.get(output) { |
| 226 | 232 | for group in &group_data.instances { |
| 227 | - let manager: &ExtWorkspaceManagerV1 = group.data().unwrap(); | |
| 233 | + let manager: &WrappedManager = group.data().unwrap(); | |
| 228 | 234 | for workspace in &data.instances { |
| 229 | 235 | if workspace.data() == Some(manager) { |
| 230 | 236 | if enter { |
| @@ -407,14 +413,14 @@ impl ExtWorkspaceGroupData { | ||
| 407 | 413 | output: &Output, |
| 408 | 414 | ) -> &ExtWorkspaceGroupHandleV1 |
| 409 | 415 | where |
| 410 | - D: Dispatch<ExtWorkspaceGroupHandleV1, ExtWorkspaceManagerV1>, | |
| 416 | + D: Dispatch<ExtWorkspaceGroupHandleV1, WrappedManager>, | |
| 411 | 417 | D: 'static, |
| 412 | 418 | { |
| 413 | 419 | let group = client |
| 414 | 420 | .create_resource::<ExtWorkspaceGroupHandleV1, _, D>( |
| 415 | 421 | handle, |
| 416 | 422 | manager.version(), |
| 417 | - manager.clone(), | |
| 423 | + WrappedManager(manager.clone()), | |
| 418 | 424 | ) |
| 419 | 425 | .unwrap(); |
| 420 | 426 | manager.workspace_group(&group); |
| @@ -438,14 +444,14 @@ impl ExtWorkspaceData { | ||
| 438 | 444 | manager: &ExtWorkspaceManagerV1, |
| 439 | 445 | ) -> &ExtWorkspaceHandleV1 |
| 440 | 446 | where |
| 441 | - D: Dispatch<ExtWorkspaceHandleV1, ExtWorkspaceManagerV1>, | |
| 447 | + D: Dispatch<ExtWorkspaceHandleV1, WrappedManager>, | |
| 442 | 448 | D: 'static, |
| 443 | 449 | { |
| 444 | 450 | let workspace = client |
| 445 | 451 | .create_resource::<ExtWorkspaceHandleV1, _, D>( |
| 446 | 452 | handle, |
| 447 | 453 | manager.version(), |
| 448 | - manager.clone(), | |
| 454 | + WrappedManager(manager.clone()), | |
| 449 | 455 | ) |
| 450 | 456 | .unwrap(); |
| 451 | 457 | manager.workspace(&workspace); |
| @@ -476,7 +482,6 @@ impl ExtWorkspaceManagerState { | ||
| 476 | 482 | pub fn new<D, F>(display: &DisplayHandle, filter: F) -> Self |
| 477 | 483 | where |
| 478 | 484 | D: GlobalDispatch<ExtWorkspaceManagerV1, ExtWorkspaceGlobalData>, |
| 479 | - D: Dispatch<ExtWorkspaceManagerV1, ()>, | |
| 480 | 485 | D: 'static, |
| 481 | 486 | F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, |
| 482 | 487 | { |
| @@ -493,23 +498,21 @@ impl ExtWorkspaceManagerState { | ||
| 493 | 498 | } |
| 494 | 499 | } |
| 495 | 500 | |
| 496 | -impl<D> GlobalDispatch<ExtWorkspaceManagerV1, ExtWorkspaceGlobalData, D> | |
| 497 | - for ExtWorkspaceManagerState | |
| 501 | +impl<D> GlobalDispatch2<ExtWorkspaceManagerV1, D> for ExtWorkspaceGlobalData | |
| 498 | 502 | where |
| 499 | - D: GlobalDispatch<ExtWorkspaceManagerV1, ExtWorkspaceGlobalData>, | |
| 500 | - D: Dispatch<ExtWorkspaceManagerV1, ()>, | |
| 501 | - D: Dispatch<ExtWorkspaceHandleV1, ExtWorkspaceManagerV1>, | |
| 503 | + D: Dispatch<ExtWorkspaceManagerV1, EmptyData>, | |
| 504 | + D: Dispatch<ExtWorkspaceHandleV1, WrappedManager>, | |
| 502 | 505 | D: ExtWorkspaceHandler, |
| 503 | 506 | { |
| 504 | 507 | fn bind( |
| 508 | + &self, | |
| 505 | 509 | state: &mut D, |
| 506 | 510 | handle: &DisplayHandle, |
| 507 | 511 | client: &Client, |
| 508 | 512 | resource: New<ExtWorkspaceManagerV1>, |
| 509 | - _global_data: &ExtWorkspaceGlobalData, | |
| 510 | 513 | data_init: &mut DataInit<'_, D>, |
| 511 | 514 | ) { |
| 512 | - let manager = data_init.init(resource, ()); | |
| 515 | + let manager = data_init.init(resource, EmptyData); | |
| 513 | 516 | |
| 514 | 517 | let state = state.ext_workspace_manager_state(); |
| 515 | 518 | |
| @@ -537,22 +540,21 @@ where | ||
| 537 | 540 | state.instances.insert(manager, Vec::new()); |
| 538 | 541 | } |
| 539 | 542 | |
| 540 | - fn can_view(client: Client, global_data: &ExtWorkspaceGlobalData) -> bool { | |
| 541 | - (global_data.filter)(&client) | |
| 543 | + fn can_view(&self, client: &Client) -> bool { | |
| 544 | + (self.filter)(client) | |
| 542 | 545 | } |
| 543 | 546 | } |
| 544 | 547 | |
| 545 | -impl<D> Dispatch<ExtWorkspaceManagerV1, (), D> for ExtWorkspaceManagerState | |
| 548 | +impl<D> Dispatch2<ExtWorkspaceManagerV1, D> for EmptyData | |
| 546 | 549 | where |
| 547 | - D: Dispatch<ExtWorkspaceManagerV1, ()>, | |
| 548 | 550 | D: ExtWorkspaceHandler, |
| 549 | 551 | { |
| 550 | 552 | fn request( |
| 553 | + &self, | |
| 551 | 554 | state: &mut D, |
| 552 | 555 | _client: &Client, |
| 553 | 556 | resource: &ExtWorkspaceManagerV1, |
| 554 | 557 | request: <ExtWorkspaceManagerV1 as Resource>::Request, |
| 555 | - _data: &(), | |
| 556 | 558 | _dhandle: &DisplayHandle, |
| 557 | 559 | _data_init: &mut DataInit<'_, D>, |
| 558 | 560 | ) { |
| @@ -581,37 +583,38 @@ where | ||
| 581 | 583 | let state = state.ext_workspace_manager_state(); |
| 582 | 584 | state.instances.retain(|x, _| x != resource); |
| 583 | 585 | |
| 586 | + let manager = WrappedManager(resource.clone()); | |
| 587 | + | |
| 584 | 588 | for data in state.workspace_groups.values_mut() { |
| 585 | 589 | data.instances |
| 586 | - .retain(|instance| instance.data() != Some(resource)); | |
| 590 | + .retain(|instance| instance.data() != Some(&manager)); | |
| 587 | 591 | } |
| 588 | 592 | |
| 589 | 593 | for data in state.workspaces.values_mut() { |
| 590 | 594 | data.instances |
| 591 | - .retain(|instance| instance.data() != Some(resource)); | |
| 595 | + .retain(|instance| instance.data() != Some(&manager)); | |
| 592 | 596 | } |
| 593 | 597 | } |
| 594 | 598 | _ => unreachable!(), |
| 595 | 599 | } |
| 596 | 600 | } |
| 597 | 601 | |
| 598 | - fn destroyed(state: &mut D, _client: ClientId, resource: &ExtWorkspaceManagerV1, _data: &()) { | |
| 602 | + fn destroyed(&self, state: &mut D, _client: ClientId, resource: &ExtWorkspaceManagerV1) { | |
| 599 | 603 | let state = state.ext_workspace_manager_state(); |
| 600 | 604 | state.instances.retain(|x, _| x != resource); |
| 601 | 605 | } |
| 602 | 606 | } |
| 603 | 607 | |
| 604 | -impl<D> Dispatch<ExtWorkspaceHandleV1, ExtWorkspaceManagerV1, D> for ExtWorkspaceManagerState | |
| 608 | +impl<D> Dispatch2<ExtWorkspaceHandleV1, D> for WrappedManager | |
| 605 | 609 | where |
| 606 | - D: Dispatch<ExtWorkspaceHandleV1, ExtWorkspaceManagerV1>, | |
| 607 | 610 | D: ExtWorkspaceHandler, |
| 608 | 611 | { |
| 609 | 612 | fn request( |
| 613 | + &self, | |
| 610 | 614 | state: &mut D, |
| 611 | 615 | _client: &Client, |
| 612 | 616 | resource: &ExtWorkspaceHandleV1, |
| 613 | 617 | request: <ExtWorkspaceHandleV1 as Resource>::Request, |
| 614 | - data: &ExtWorkspaceManagerV1, | |
| 615 | 618 | _dhandle: &DisplayHandle, |
| 616 | 619 | _data_init: &mut DataInit<'_, D>, |
| 617 | 620 | ) { |
| @@ -628,7 +631,7 @@ where | ||
| 628 | 631 | |
| 629 | 632 | match request { |
| 630 | 633 | ext_workspace_handle_v1::Request::Activate => { |
| 631 | - let actions = protocol_state.instances.get_mut(data).unwrap(); | |
| 634 | + let actions = protocol_state.instances.get_mut(&self.0).unwrap(); | |
| 632 | 635 | actions.push(Action::Activate(workspace)); |
| 633 | 636 | } |
| 634 | 637 | ext_workspace_handle_v1::Request::Deactivate => (), |
| @@ -639,7 +642,7 @@ where | ||
| 639 | 642 | .find(|(_, data)| data.instances.contains(&workspace_group)) |
| 640 | 643 | .map(|(output, _)| output.clone()) |
| 641 | 644 | { |
| 642 | - let actions = protocol_state.instances.get_mut(data).unwrap(); | |
| 645 | + let actions = protocol_state.instances.get_mut(&self.0).unwrap(); | |
| 643 | 646 | actions.push(Action::Assign(workspace, output.downgrade())); |
| 644 | 647 | } |
| 645 | 648 | } |
| @@ -649,12 +652,7 @@ where | ||
| 649 | 652 | } |
| 650 | 653 | } |
| 651 | 654 | |
| 652 | - fn destroyed( | |
| 653 | - state: &mut D, | |
| 654 | - _client: ClientId, | |
| 655 | - resource: &ExtWorkspaceHandleV1, | |
| 656 | - _data: &ExtWorkspaceManagerV1, | |
| 657 | - ) { | |
| 655 | + fn destroyed(&self, state: &mut D, _client: ClientId, resource: &ExtWorkspaceHandleV1) { | |
| 658 | 656 | let state = state.ext_workspace_manager_state(); |
| 659 | 657 | for data in state.workspaces.values_mut() { |
| 660 | 658 | data.instances.retain(|instance| instance != resource); |
| @@ -662,17 +660,16 @@ where | ||
| 662 | 660 | } |
| 663 | 661 | } |
| 664 | 662 | |
| 665 | -impl<D> Dispatch<ExtWorkspaceGroupHandleV1, ExtWorkspaceManagerV1, D> for ExtWorkspaceManagerState | |
| 663 | +impl<D> Dispatch2<ExtWorkspaceGroupHandleV1, D> for WrappedManager | |
| 666 | 664 | where |
| 667 | - D: Dispatch<ExtWorkspaceGroupHandleV1, ExtWorkspaceManagerV1>, | |
| 668 | 665 | D: ExtWorkspaceHandler, |
| 669 | 666 | { |
| 670 | 667 | fn request( |
| 668 | + &self, | |
| 671 | 669 | _state: &mut D, |
| 672 | 670 | _client: &Client, |
| 673 | 671 | _resource: &ExtWorkspaceGroupHandleV1, |
| 674 | 672 | request: <ExtWorkspaceGroupHandleV1 as Resource>::Request, |
| 675 | - _data: &ExtWorkspaceManagerV1, | |
| 676 | 673 | _dhandle: &DisplayHandle, |
| 677 | 674 | _data_init: &mut DataInit<'_, D>, |
| 678 | 675 | ) { |
| @@ -683,33 +680,10 @@ where | ||
| 683 | 680 | } |
| 684 | 681 | } |
| 685 | 682 | |
| 686 | - fn destroyed( | |
| 687 | - state: &mut D, | |
| 688 | - _client: ClientId, | |
| 689 | - resource: &ExtWorkspaceGroupHandleV1, | |
| 690 | - _data: &ExtWorkspaceManagerV1, | |
| 691 | - ) { | |
| 683 | + fn destroyed(&self, state: &mut D, _client: ClientId, resource: &ExtWorkspaceGroupHandleV1) { | |
| 692 | 684 | let state = state.ext_workspace_manager_state(); |
| 693 | 685 | for data in state.workspace_groups.values_mut() { |
| 694 | 686 | data.instances.retain(|instance| instance != resource); |
| 695 | 687 | } |
| 696 | 688 | } |
| 697 | 689 | } |
| 698 | - | |
| 699 | -#[macro_export] | |
| 700 | -macro_rules! delegate_ext_workspace { | |
| 701 | - ($(@<$( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+>)? $ty: ty) => { | |
| 702 | - smithay::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 703 | - smithay::reexports::wayland_protocols::ext::workspace::v1::server::ext_workspace_manager_v1::ExtWorkspaceManagerV1: $crate::protocols::ext_workspace::ExtWorkspaceGlobalData | |
| 704 | - ] => $crate::protocols::ext_workspace::ExtWorkspaceManagerState); | |
| 705 | - smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 706 | - smithay::reexports::wayland_protocols::ext::workspace::v1::server::ext_workspace_manager_v1::ExtWorkspaceManagerV1: () | |
| 707 | - ] => $crate::protocols::ext_workspace::ExtWorkspaceManagerState); | |
| 708 | - smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 709 | - smithay::reexports::wayland_protocols::ext::workspace::v1::server::ext_workspace_handle_v1::ExtWorkspaceHandleV1: smithay::reexports::wayland_protocols::ext::workspace::v1::server::ext_workspace_manager_v1::ExtWorkspaceManagerV1 | |
| 710 | - ] => $crate::protocols::ext_workspace::ExtWorkspaceManagerState); | |
| 711 | - smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 712 | - smithay::reexports::wayland_protocols::ext::workspace::v1::server::ext_workspace_group_handle_v1::ExtWorkspaceGroupHandleV1: smithay::reexports::wayland_protocols::ext::workspace::v1::server::ext_workspace_manager_v1::ExtWorkspaceManagerV1 | |
| 713 | - ] => $crate::protocols::ext_workspace::ExtWorkspaceManagerState); | |
| 714 | - }; | |
| 715 | -} |
src/protocols/foreign_toplevel.rsmodified+40 -85
| @@ -17,11 +17,13 @@ use smithay::reexports::wayland_server::protocol::wl_surface::WlSurface; | ||
| 17 | 17 | use smithay::reexports::wayland_server::{ |
| 18 | 18 | Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, |
| 19 | 19 | }; |
| 20 | +use smithay::wayland::{Dispatch2, GlobalDispatch2}; | |
| 20 | 21 | use smithay::wayland::shell::xdg::{ |
| 21 | 22 | ToplevelState, ToplevelStateSet, XdgToplevelSurfaceRoleAttributes |
| 22 | 23 | }; |
| 23 | 24 | |
| 24 | 25 | use crate::niri::State; |
| 26 | +use crate::protocols::EmptyData; | |
| 25 | 27 | use crate::window::mapped::MappedId; |
| 26 | 28 | use crate::utils::with_toplevel_role_and_current; |
| 27 | 29 | |
| @@ -67,8 +69,6 @@ impl ForeignToplevelManagerState { | ||
| 67 | 69 | where |
| 68 | 70 | D: GlobalDispatch<ZwlrForeignToplevelManagerV1, ForeignToplevelGlobalData>, |
| 69 | 71 | D: GlobalDispatch<ExtForeignToplevelListV1, ForeignToplevelGlobalData>, |
| 70 | - D: Dispatch<ZwlrForeignToplevelManagerV1, ()>, | |
| 71 | - D: Dispatch<ExtForeignToplevelListV1, ()>, | |
| 72 | 72 | D: 'static, |
| 73 | 73 | F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, |
| 74 | 74 | { |
| @@ -323,11 +323,15 @@ impl ToplevelData { | ||
| 323 | 323 | client: &Client, |
| 324 | 324 | manager: &ExtForeignToplevelListV1, |
| 325 | 325 | ) where |
| 326 | - D: Dispatch<ExtForeignToplevelHandleV1, ()>, | |
| 326 | + D: Dispatch<ExtForeignToplevelHandleV1, EmptyData>, | |
| 327 | 327 | D: 'static, |
| 328 | 328 | { |
| 329 | 329 | let toplevel = client |
| 330 | - .create_resource::<ExtForeignToplevelHandleV1, _, D>(handle, manager.version(), ()) | |
| 330 | + .create_resource::<ExtForeignToplevelHandleV1, _, D>( | |
| 331 | + handle, | |
| 332 | + manager.version(), | |
| 333 | + EmptyData, | |
| 334 | + ) | |
| 331 | 335 | .unwrap(); |
| 332 | 336 | manager.toplevel(&toplevel); |
| 333 | 337 | |
| @@ -351,11 +355,15 @@ impl ToplevelData { | ||
| 351 | 355 | client: &Client, |
| 352 | 356 | manager: &ZwlrForeignToplevelManagerV1, |
| 353 | 357 | ) where |
| 354 | - D: Dispatch<ZwlrForeignToplevelHandleV1, ()>, | |
| 358 | + D: Dispatch<ZwlrForeignToplevelHandleV1, EmptyData>, | |
| 355 | 359 | D: 'static, |
| 356 | 360 | { |
| 357 | 361 | let toplevel = client |
| 358 | - .create_resource::<ZwlrForeignToplevelHandleV1, _, D>(handle, manager.version(), ()) | |
| 362 | + .create_resource::<ZwlrForeignToplevelHandleV1, _, D>( | |
| 363 | + handle, | |
| 364 | + manager.version(), | |
| 365 | + EmptyData, | |
| 366 | + ) | |
| 359 | 367 | .unwrap(); |
| 360 | 368 | manager.toplevel(&toplevel); |
| 361 | 369 | |
| @@ -382,23 +390,21 @@ impl ToplevelData { | ||
| 382 | 390 | } |
| 383 | 391 | } |
| 384 | 392 | |
| 385 | -impl<D> GlobalDispatch<ExtForeignToplevelListV1, ForeignToplevelGlobalData, D> | |
| 386 | - for ForeignToplevelManagerState | |
| 393 | +impl<D> GlobalDispatch2<ExtForeignToplevelListV1, D> for ForeignToplevelGlobalData | |
| 387 | 394 | where |
| 388 | - D: GlobalDispatch<ExtForeignToplevelListV1, ForeignToplevelGlobalData>, | |
| 389 | - D: Dispatch<ExtForeignToplevelListV1, ()>, | |
| 390 | - D: Dispatch<ExtForeignToplevelHandleV1, ()>, | |
| 395 | + D: Dispatch<ExtForeignToplevelListV1, EmptyData>, | |
| 396 | + D: Dispatch<ExtForeignToplevelHandleV1, EmptyData>, | |
| 391 | 397 | D: ForeignToplevelHandler, |
| 392 | 398 | { |
| 393 | 399 | fn bind( |
| 400 | + &self, | |
| 394 | 401 | state: &mut D, |
| 395 | 402 | handle: &DisplayHandle, |
| 396 | 403 | client: &Client, |
| 397 | 404 | resource: New<ExtForeignToplevelListV1>, |
| 398 | - _global_data: &ForeignToplevelGlobalData, | |
| 399 | 405 | data_init: &mut DataInit<'_, D>, |
| 400 | 406 | ) { |
| 401 | - let manager = data_init.init(resource, ()); | |
| 407 | + let manager = data_init.init(resource, EmptyData); | |
| 402 | 408 | |
| 403 | 409 | let state = state.foreign_toplevel_manager_state(); |
| 404 | 410 | |
| @@ -409,22 +415,21 @@ where | ||
| 409 | 415 | state.ext_list_instances.insert(manager); |
| 410 | 416 | } |
| 411 | 417 | |
| 412 | - fn can_view(client: Client, global_data: &ForeignToplevelGlobalData) -> bool { | |
| 413 | - (global_data.filter)(&client) | |
| 418 | + fn can_view(&self, client: &Client) -> bool { | |
| 419 | + (self.filter)(client) | |
| 414 | 420 | } |
| 415 | 421 | } |
| 416 | 422 | |
| 417 | -impl<D> Dispatch<ExtForeignToplevelListV1, (), D> for ForeignToplevelManagerState | |
| 423 | +impl<D> Dispatch2<ExtForeignToplevelListV1, D> for EmptyData | |
| 418 | 424 | where |
| 419 | - D: Dispatch<ExtForeignToplevelListV1, ()>, | |
| 420 | 425 | D: ForeignToplevelHandler, |
| 421 | 426 | { |
| 422 | 427 | fn request( |
| 428 | + &self, | |
| 423 | 429 | state: &mut D, |
| 424 | 430 | _client: &Client, |
| 425 | 431 | resource: &ExtForeignToplevelListV1, |
| 426 | 432 | request: <ExtForeignToplevelListV1 as Resource>::Request, |
| 427 | - _data: &(), | |
| 428 | 433 | _dhandle: &DisplayHandle, |
| 429 | 434 | _data_init: &mut DataInit<'_, D>, |
| 430 | 435 | ) { |
| @@ -441,29 +446,23 @@ where | ||
| 441 | 446 | } |
| 442 | 447 | } |
| 443 | 448 | |
| 444 | - fn destroyed( | |
| 445 | - state: &mut D, | |
| 446 | - _client: ClientId, | |
| 447 | - resource: &ExtForeignToplevelListV1, | |
| 448 | - _data: &(), | |
| 449 | - ) { | |
| 449 | + fn destroyed(&self, state: &mut D, _client: ClientId, resource: &ExtForeignToplevelListV1) { | |
| 450 | 450 | // also remove the instance here, in case `stop` was never sent, e.g. sudden disconnect. |
| 451 | 451 | let state = state.foreign_toplevel_manager_state(); |
| 452 | 452 | state.ext_list_instances.remove(resource); |
| 453 | 453 | } |
| 454 | 454 | } |
| 455 | 455 | |
| 456 | -impl<D> Dispatch<ExtForeignToplevelHandleV1, (), D> for ForeignToplevelManagerState | |
| 456 | +impl<D> Dispatch2<ExtForeignToplevelHandleV1, D> for EmptyData | |
| 457 | 457 | where |
| 458 | - D: Dispatch<ExtForeignToplevelHandleV1, ()>, | |
| 459 | 458 | D: ForeignToplevelHandler, |
| 460 | 459 | { |
| 461 | 460 | fn request( |
| 461 | + &self, | |
| 462 | 462 | _state: &mut D, |
| 463 | 463 | _client: &Client, |
| 464 | 464 | _resource: &ExtForeignToplevelHandleV1, |
| 465 | 465 | request: <ExtForeignToplevelHandleV1 as Resource>::Request, |
| 466 | - _data: &(), | |
| 467 | 466 | _dhandle: &DisplayHandle, |
| 468 | 467 | _data_init: &mut DataInit<'_, D>, |
| 469 | 468 | ) { |
| @@ -473,12 +472,7 @@ where | ||
| 473 | 472 | } |
| 474 | 473 | } |
| 475 | 474 | |
| 476 | - fn destroyed( | |
| 477 | - state: &mut D, | |
| 478 | - _client: ClientId, | |
| 479 | - resource: &ExtForeignToplevelHandleV1, | |
| 480 | - _data: &(), | |
| 481 | - ) { | |
| 475 | + fn destroyed(&self, state: &mut D, _client: ClientId, resource: &ExtForeignToplevelHandleV1) { | |
| 482 | 476 | let state = state.foreign_toplevel_manager_state(); |
| 483 | 477 | for data in state.toplevels.values_mut() { |
| 484 | 478 | data.ext_list_instances.remove(resource); |
| @@ -486,23 +480,21 @@ where | ||
| 486 | 480 | } |
| 487 | 481 | } |
| 488 | 482 | |
| 489 | -impl<D> GlobalDispatch<ZwlrForeignToplevelManagerV1, ForeignToplevelGlobalData, D> | |
| 490 | - for ForeignToplevelManagerState | |
| 483 | +impl<D> GlobalDispatch2<ZwlrForeignToplevelManagerV1, D> for ForeignToplevelGlobalData | |
| 491 | 484 | where |
| 492 | - D: GlobalDispatch<ZwlrForeignToplevelManagerV1, ForeignToplevelGlobalData>, | |
| 493 | - D: Dispatch<ZwlrForeignToplevelManagerV1, ()>, | |
| 494 | - D: Dispatch<ZwlrForeignToplevelHandleV1, ()>, | |
| 485 | + D: Dispatch<ZwlrForeignToplevelManagerV1, EmptyData>, | |
| 486 | + D: Dispatch<ZwlrForeignToplevelHandleV1, EmptyData>, | |
| 495 | 487 | D: ForeignToplevelHandler, |
| 496 | 488 | { |
| 497 | 489 | fn bind( |
| 490 | + &self, | |
| 498 | 491 | state: &mut D, |
| 499 | 492 | handle: &DisplayHandle, |
| 500 | 493 | client: &Client, |
| 501 | 494 | resource: New<ZwlrForeignToplevelManagerV1>, |
| 502 | - _global_data: &ForeignToplevelGlobalData, | |
| 503 | 495 | data_init: &mut DataInit<'_, D>, |
| 504 | 496 | ) { |
| 505 | - let manager = data_init.init(resource, ()); | |
| 497 | + let manager = data_init.init(resource, EmptyData); | |
| 506 | 498 | |
| 507 | 499 | let state = state.foreign_toplevel_manager_state(); |
| 508 | 500 | |
| @@ -513,22 +505,21 @@ where | ||
| 513 | 505 | state.wlr_management_instances.insert(manager); |
| 514 | 506 | } |
| 515 | 507 | |
| 516 | - fn can_view(client: Client, global_data: &ForeignToplevelGlobalData) -> bool { | |
| 517 | - (global_data.filter)(&client) | |
| 508 | + fn can_view(&self, client: &Client) -> bool { | |
| 509 | + (self.filter)(client) | |
| 518 | 510 | } |
| 519 | 511 | } |
| 520 | 512 | |
| 521 | -impl<D> Dispatch<ZwlrForeignToplevelManagerV1, (), D> for ForeignToplevelManagerState | |
| 513 | +impl<D> Dispatch2<ZwlrForeignToplevelManagerV1, D> for EmptyData | |
| 522 | 514 | where |
| 523 | - D: Dispatch<ZwlrForeignToplevelManagerV1, ()>, | |
| 524 | 515 | D: ForeignToplevelHandler, |
| 525 | 516 | { |
| 526 | 517 | fn request( |
| 518 | + &self, | |
| 527 | 519 | state: &mut D, |
| 528 | 520 | _client: &Client, |
| 529 | 521 | resource: &ZwlrForeignToplevelManagerV1, |
| 530 | 522 | request: <ZwlrForeignToplevelManagerV1 as Resource>::Request, |
| 531 | - _data: &(), | |
| 532 | 523 | _dhandle: &DisplayHandle, |
| 533 | 524 | _data_init: &mut DataInit<'_, D>, |
| 534 | 525 | ) { |
| @@ -544,29 +535,23 @@ where | ||
| 544 | 535 | } |
| 545 | 536 | } |
| 546 | 537 | |
| 547 | - fn destroyed( | |
| 548 | - state: &mut D, | |
| 549 | - _client: ClientId, | |
| 550 | - resource: &ZwlrForeignToplevelManagerV1, | |
| 551 | - _data: &(), | |
| 552 | - ) { | |
| 538 | + fn destroyed(&self, state: &mut D, _client: ClientId, resource: &ZwlrForeignToplevelManagerV1) { | |
| 553 | 539 | // also remove the instance here, in case `stop` was never sent, e.g. sudden disconnect. |
| 554 | 540 | let state = state.foreign_toplevel_manager_state(); |
| 555 | 541 | state.wlr_management_instances.remove(resource); |
| 556 | 542 | } |
| 557 | 543 | } |
| 558 | 544 | |
| 559 | -impl<D> Dispatch<ZwlrForeignToplevelHandleV1, (), D> for ForeignToplevelManagerState | |
| 545 | +impl<D> Dispatch2<ZwlrForeignToplevelHandleV1, D> for EmptyData | |
| 560 | 546 | where |
| 561 | - D: Dispatch<ZwlrForeignToplevelHandleV1, ()>, | |
| 562 | 547 | D: ForeignToplevelHandler, |
| 563 | 548 | { |
| 564 | 549 | fn request( |
| 550 | + &self, | |
| 565 | 551 | state: &mut D, |
| 566 | 552 | _client: &Client, |
| 567 | 553 | resource: &ZwlrForeignToplevelHandleV1, |
| 568 | 554 | request: <ZwlrForeignToplevelHandleV1 as Resource>::Request, |
| 569 | - _data: &(), | |
| 570 | 555 | _dhandle: &DisplayHandle, |
| 571 | 556 | _data_init: &mut DataInit<'_, D>, |
| 572 | 557 | ) { |
| @@ -606,12 +591,7 @@ where | ||
| 606 | 591 | } |
| 607 | 592 | } |
| 608 | 593 | |
| 609 | - fn destroyed( | |
| 610 | - state: &mut D, | |
| 611 | - _client: ClientId, | |
| 612 | - resource: &ZwlrForeignToplevelHandleV1, | |
| 613 | - _data: &(), | |
| 614 | - ) { | |
| 594 | + fn destroyed(&self, state: &mut D, _client: ClientId, resource: &ZwlrForeignToplevelHandleV1) { | |
| 615 | 595 | let state = state.foreign_toplevel_manager_state(); |
| 616 | 596 | for data in state.toplevels.values_mut() { |
| 617 | 597 | data.wlr_management_instances.remove(resource); |
| @@ -642,28 +622,3 @@ fn to_state_vec(states: &ToplevelStateSet, has_focus: bool) -> ArrayVec<u32, 3> | ||
| 642 | 622 | |
| 643 | 623 | rv |
| 644 | 624 | } |
| 645 | - | |
| 646 | -#[macro_export] | |
| 647 | -macro_rules! delegate_foreign_toplevel { | |
| 648 | - ($(@<$( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+>)? $ty: ty) => { | |
| 649 | - smithay::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 650 | - smithay::reexports::wayland_protocols::ext::foreign_toplevel_list::v1::server::ext_foreign_toplevel_list_v1::ExtForeignToplevelListV1: $crate::protocols::foreign_toplevel::ForeignToplevelGlobalData | |
| 651 | - ] => $crate::protocols::foreign_toplevel::ForeignToplevelManagerState); | |
| 652 | - smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 653 | - smithay::reexports::wayland_protocols::ext::foreign_toplevel_list::v1::server::ext_foreign_toplevel_list_v1::ExtForeignToplevelListV1: () | |
| 654 | - ] => $crate::protocols::foreign_toplevel::ForeignToplevelManagerState); | |
| 655 | - smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 656 | - smithay::reexports::wayland_protocols::ext::foreign_toplevel_list::v1::server::ext_foreign_toplevel_handle_v1::ExtForeignToplevelHandleV1: () | |
| 657 | - ] => $crate::protocols::foreign_toplevel::ForeignToplevelManagerState); | |
| 658 | - | |
| 659 | - smithay::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 660 | - smithay::reexports::wayland_protocols_wlr::foreign_toplevel::v1::server::zwlr_foreign_toplevel_manager_v1::ZwlrForeignToplevelManagerV1: $crate::protocols::foreign_toplevel::ForeignToplevelGlobalData | |
| 661 | - ] => $crate::protocols::foreign_toplevel::ForeignToplevelManagerState); | |
| 662 | - smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 663 | - smithay::reexports::wayland_protocols_wlr::foreign_toplevel::v1::server::zwlr_foreign_toplevel_manager_v1::ZwlrForeignToplevelManagerV1: () | |
| 664 | - ] => $crate::protocols::foreign_toplevel::ForeignToplevelManagerState); | |
| 665 | - smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 666 | - smithay::reexports::wayland_protocols_wlr::foreign_toplevel::v1::server::zwlr_foreign_toplevel_handle_v1::ZwlrForeignToplevelHandleV1: () | |
| 667 | - ] => $crate::protocols::foreign_toplevel::ForeignToplevelManagerState); | |
| 668 | - }; | |
| 669 | -} |
src/protocols/gamma_control.rsmodified+15 -41
| @@ -8,12 +8,15 @@ use smithay::reexports::wayland_server::backend::ClientId; | ||
| 8 | 8 | use smithay::reexports::wayland_server::{ |
| 9 | 9 | Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, |
| 10 | 10 | }; |
| 11 | +use smithay::wayland::{Dispatch2, GlobalDispatch2}; | |
| 11 | 12 | use wayland_protocols_wlr::gamma_control::v1::server::{ |
| 12 | 13 | zwlr_gamma_control_manager_v1, zwlr_gamma_control_v1, |
| 13 | 14 | }; |
| 14 | 15 | use zwlr_gamma_control_manager_v1::ZwlrGammaControlManagerV1; |
| 15 | 16 | use zwlr_gamma_control_v1::ZwlrGammaControlV1; |
| 16 | 17 | |
| 18 | +use crate::protocols::EmptyData; | |
| 19 | + | |
| 17 | 20 | const VERSION: u32 = 1; |
| 18 | 21 | |
| 19 | 22 | pub struct GammaControlManagerState { |
| @@ -39,8 +42,6 @@ impl GammaControlManagerState { | ||
| 39 | 42 | pub fn new<D, F>(display: &DisplayHandle, filter: F) -> Self |
| 40 | 43 | where |
| 41 | 44 | D: GlobalDispatch<ZwlrGammaControlManagerV1, GammaControlManagerGlobalData>, |
| 42 | - D: Dispatch<ZwlrGammaControlManagerV1, ()>, | |
| 43 | - D: Dispatch<ZwlrGammaControlV1, GammaControlState>, | |
| 44 | 45 | D: GammaControlHandler, |
| 45 | 46 | D: 'static, |
| 46 | 47 | F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, |
| @@ -62,44 +63,40 @@ impl GammaControlManagerState { | ||
| 62 | 63 | } |
| 63 | 64 | } |
| 64 | 65 | |
| 65 | -impl<D> GlobalDispatch<ZwlrGammaControlManagerV1, GammaControlManagerGlobalData, D> | |
| 66 | - for GammaControlManagerState | |
| 66 | +impl<D> GlobalDispatch2<ZwlrGammaControlManagerV1, D> for GammaControlManagerGlobalData | |
| 67 | 67 | where |
| 68 | - D: GlobalDispatch<ZwlrGammaControlManagerV1, GammaControlManagerGlobalData>, | |
| 69 | - D: Dispatch<ZwlrGammaControlManagerV1, ()>, | |
| 70 | - D: Dispatch<ZwlrGammaControlV1, GammaControlState>, | |
| 68 | + D: Dispatch<ZwlrGammaControlManagerV1, EmptyData>, | |
| 71 | 69 | D: GammaControlHandler, |
| 72 | 70 | D: 'static, |
| 73 | 71 | { |
| 74 | 72 | fn bind( |
| 73 | + &self, | |
| 75 | 74 | _state: &mut D, |
| 76 | 75 | _handle: &DisplayHandle, |
| 77 | 76 | _client: &Client, |
| 78 | 77 | manager: New<ZwlrGammaControlManagerV1>, |
| 79 | - _manager_state: &GammaControlManagerGlobalData, | |
| 80 | 78 | data_init: &mut DataInit<'_, D>, |
| 81 | 79 | ) { |
| 82 | - data_init.init(manager, ()); | |
| 80 | + data_init.init(manager, EmptyData); | |
| 83 | 81 | } |
| 84 | 82 | |
| 85 | - fn can_view(client: Client, global_data: &GammaControlManagerGlobalData) -> bool { | |
| 86 | - (global_data.filter)(&client) | |
| 83 | + fn can_view(&self, client: &Client) -> bool { | |
| 84 | + (self.filter)(client) | |
| 87 | 85 | } |
| 88 | 86 | } |
| 89 | 87 | |
| 90 | -impl<D> Dispatch<ZwlrGammaControlManagerV1, (), D> for GammaControlManagerState | |
| 88 | +impl<D> Dispatch2<ZwlrGammaControlManagerV1, D> for EmptyData | |
| 91 | 89 | where |
| 92 | - D: Dispatch<ZwlrGammaControlManagerV1, ()>, | |
| 93 | 90 | D: Dispatch<ZwlrGammaControlV1, GammaControlState>, |
| 94 | 91 | D: GammaControlHandler, |
| 95 | 92 | D: 'static, |
| 96 | 93 | { |
| 97 | 94 | fn request( |
| 95 | + &self, | |
| 98 | 96 | state: &mut D, |
| 99 | 97 | _client: &Client, |
| 100 | 98 | _resource: &ZwlrGammaControlManagerV1, |
| 101 | 99 | request: <ZwlrGammaControlManagerV1 as Resource>::Request, |
| 102 | - _data: &(), | |
| 103 | 100 | _dhandle: &DisplayHandle, |
| 104 | 101 | data_init: &mut DataInit<'_, D>, |
| 105 | 102 | ) { |
| @@ -136,18 +133,17 @@ where | ||
| 136 | 133 | } |
| 137 | 134 | } |
| 138 | 135 | |
| 139 | -impl<D> Dispatch<ZwlrGammaControlV1, GammaControlState, D> for GammaControlManagerState | |
| 136 | +impl<D> Dispatch2<ZwlrGammaControlV1, D> for GammaControlState | |
| 140 | 137 | where |
| 141 | - D: Dispatch<ZwlrGammaControlV1, GammaControlState>, | |
| 142 | 138 | D: GammaControlHandler, |
| 143 | 139 | D: 'static, |
| 144 | 140 | { |
| 145 | 141 | fn request( |
| 142 | + &self, | |
| 146 | 143 | state: &mut D, |
| 147 | 144 | _client: &Client, |
| 148 | 145 | resource: &ZwlrGammaControlV1, |
| 149 | 146 | request: <ZwlrGammaControlV1 as Resource>::Request, |
| 150 | - data: &GammaControlState, | |
| 151 | 147 | _dhandle: &DisplayHandle, |
| 152 | 148 | _data_init: &mut DataInit<'_, D>, |
| 153 | 149 | ) { |
| @@ -162,7 +158,7 @@ where | ||
| 162 | 158 | trace!("setting gamma for output {}", output.name()); |
| 163 | 159 | |
| 164 | 160 | // Start with a u16 slice so it's aligned correctly. |
| 165 | - let mut gamma = vec![0u16; data.gamma_size as usize * 3]; | |
| 161 | + let mut gamma = vec![0u16; self.gamma_size as usize * 3]; | |
| 166 | 162 | let buf = bytemuck::cast_slice_mut(&mut gamma); |
| 167 | 163 | let mut file = File::from(fd); |
| 168 | 164 | { |
| @@ -210,12 +206,7 @@ where | ||
| 210 | 206 | } |
| 211 | 207 | } |
| 212 | 208 | |
| 213 | - fn destroyed( | |
| 214 | - state: &mut D, | |
| 215 | - _client: ClientId, | |
| 216 | - resource: &ZwlrGammaControlV1, | |
| 217 | - _data: &GammaControlState, | |
| 218 | - ) { | |
| 209 | + fn destroyed(&self, state: &mut D, _client: ClientId, resource: &ZwlrGammaControlV1) { | |
| 219 | 210 | let gamma_controls = &mut state.gamma_control_manager_state().gamma_controls; |
| 220 | 211 | let Some((output, _)) = gamma_controls.iter().find(|(_, x)| *x == resource) else { |
| 221 | 212 | return; |
| @@ -226,20 +217,3 @@ where | ||
| 226 | 217 | let _ = state.set_gamma(&output, None); |
| 227 | 218 | } |
| 228 | 219 | } |
| 229 | - | |
| 230 | -#[macro_export] | |
| 231 | -macro_rules! delegate_gamma_control { | |
| 232 | - ($(@<$( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+>)? $ty: ty) => { | |
| 233 | - smithay::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 234 | - smithay::reexports::wayland_protocols_wlr::gamma_control::v1::server::zwlr_gamma_control_manager_v1::ZwlrGammaControlManagerV1: $crate::protocols::gamma_control::GammaControlManagerGlobalData | |
| 235 | - ] => $crate::protocols::gamma_control::GammaControlManagerState); | |
| 236 | - | |
| 237 | - smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 238 | - smithay::reexports::wayland_protocols_wlr::gamma_control::v1::server::zwlr_gamma_control_manager_v1::ZwlrGammaControlManagerV1: () | |
| 239 | - ] => $crate::protocols::gamma_control::GammaControlManagerState); | |
| 240 | - | |
| 241 | - smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 242 | - smithay::reexports::wayland_protocols_wlr::gamma_control::v1::server::zwlr_gamma_control_v1::ZwlrGammaControlV1: $crate::protocols::gamma_control::GammaControlState | |
| 243 | - ] => $crate::protocols::gamma_control::GammaControlManagerState); | |
| 244 | - }; | |
| 245 | -} |
src/protocols/mod.rsmodified+6 -0
| @@ -7,3 +7,9 @@ pub mod screencopy; | ||
| 7 | 7 | pub mod virtual_pointer; |
| 8 | 8 | |
| 9 | 9 | pub mod raw; |
| 10 | + | |
| 11 | +/// Empty user-data for protocol impls. | |
| 12 | +/// | |
| 13 | +/// Same as Smithay's `GlobalData` which we can't use due to coherence. | |
| 14 | +#[derive(Debug)] | |
| 15 | +pub struct EmptyData; |
src/protocols/mutter_x11_interop.rsmodified+9 -27
| @@ -2,6 +2,7 @@ use mutter_x11_interop::MutterX11Interop; | ||
| 2 | 2 | use smithay::reexports::wayland_server::{ |
| 3 | 3 | Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, |
| 4 | 4 | }; |
| 5 | +use smithay::wayland::{Dispatch2, GlobalData, GlobalDispatch2}; | |
| 5 | 6 | |
| 6 | 7 | use super::raw::mutter_x11_interop::v1::server::mutter_x11_interop; |
| 7 | 8 | |
| @@ -19,7 +20,6 @@ impl MutterX11InteropManagerState { | ||
| 19 | 20 | pub fn new<D, F>(display: &DisplayHandle, filter: F) -> Self |
| 20 | 21 | where |
| 21 | 22 | D: GlobalDispatch<MutterX11Interop, MutterX11InteropManagerGlobalData>, |
| 22 | - D: Dispatch<MutterX11Interop, ()>, | |
| 23 | 23 | D: MutterX11InteropHandler, |
| 24 | 24 | D: 'static, |
| 25 | 25 | F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, |
| @@ -33,42 +33,37 @@ impl MutterX11InteropManagerState { | ||
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | -impl<D> GlobalDispatch<MutterX11Interop, MutterX11InteropManagerGlobalData, D> | |
| 37 | - for MutterX11InteropManagerState | |
| 36 | +impl<D> GlobalDispatch2<MutterX11Interop, D> for MutterX11InteropManagerGlobalData | |
| 38 | 37 | where |
| 39 | - D: GlobalDispatch<MutterX11Interop, MutterX11InteropManagerGlobalData>, | |
| 40 | - D: Dispatch<MutterX11Interop, ()>, | |
| 38 | + D: Dispatch<MutterX11Interop, GlobalData>, | |
| 41 | 39 | D: MutterX11InteropHandler, |
| 42 | - D: 'static, | |
| 43 | 40 | { |
| 44 | 41 | fn bind( |
| 42 | + &self, | |
| 45 | 43 | _state: &mut D, |
| 46 | 44 | _handle: &DisplayHandle, |
| 47 | 45 | _client: &Client, |
| 48 | 46 | manager: New<MutterX11Interop>, |
| 49 | - _manager_state: &MutterX11InteropManagerGlobalData, | |
| 50 | 47 | data_init: &mut DataInit<'_, D>, |
| 51 | 48 | ) { |
| 52 | - data_init.init(manager, ()); | |
| 49 | + data_init.init(manager, GlobalData); | |
| 53 | 50 | } |
| 54 | 51 | |
| 55 | - fn can_view(client: Client, global_data: &MutterX11InteropManagerGlobalData) -> bool { | |
| 56 | - (global_data.filter)(&client) | |
| 52 | + fn can_view(&self, client: &Client) -> bool { | |
| 53 | + (self.filter)(client) | |
| 57 | 54 | } |
| 58 | 55 | } |
| 59 | 56 | |
| 60 | -impl<D> Dispatch<MutterX11Interop, (), D> for MutterX11InteropManagerState | |
| 57 | +impl<D> Dispatch2<MutterX11Interop, D> for GlobalData | |
| 61 | 58 | where |
| 62 | - D: Dispatch<MutterX11Interop, ()>, | |
| 63 | 59 | D: MutterX11InteropHandler, |
| 64 | - D: 'static, | |
| 65 | 60 | { |
| 66 | 61 | fn request( |
| 62 | + &self, | |
| 67 | 63 | _state: &mut D, |
| 68 | 64 | _client: &Client, |
| 69 | 65 | _resource: &MutterX11Interop, |
| 70 | 66 | request: <MutterX11Interop as Resource>::Request, |
| 71 | - _data: &(), | |
| 72 | 67 | _dhandle: &DisplayHandle, |
| 73 | 68 | _data_init: &mut DataInit<'_, D>, |
| 74 | 69 | ) { |
| @@ -78,16 +73,3 @@ where | ||
| 78 | 73 | } |
| 79 | 74 | } |
| 80 | 75 | } |
| 81 | - | |
| 82 | -#[macro_export] | |
| 83 | -macro_rules! delegate_mutter_x11_interop { | |
| 84 | - ($(@<$( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+>)? $ty: ty) => { | |
| 85 | - smithay::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 86 | - $crate::protocols::raw::mutter_x11_interop::v1::server::mutter_x11_interop::MutterX11Interop: $crate::protocols::mutter_x11_interop::MutterX11InteropManagerGlobalData | |
| 87 | - ] => $crate::protocols::mutter_x11_interop::MutterX11InteropManagerState); | |
| 88 | - | |
| 89 | - smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 90 | - $crate::protocols::raw::mutter_x11_interop::v1::server::mutter_x11_interop::MutterX11Interop: () | |
| 91 | - ] => $crate::protocols::mutter_x11_interop::MutterX11InteropManagerState); | |
| 92 | - }; | |
| 93 | -} |
src/protocols/output_management.rsmodified+36 -97
| @@ -14,6 +14,7 @@ use smithay::reexports::wayland_server::protocol::wl_output::Transform as WlTran | ||
| 14 | 14 | use smithay::reexports::wayland_server::{ |
| 15 | 15 | Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, WEnum, |
| 16 | 16 | }; |
| 17 | +use smithay::wayland::{Dispatch2, GlobalDispatch2}; | |
| 17 | 18 | use zwlr_output_configuration_head_v1::ZwlrOutputConfigurationHeadV1; |
| 18 | 19 | use zwlr_output_configuration_v1::ZwlrOutputConfigurationV1; |
| 19 | 20 | use zwlr_output_head_v1::{AdaptiveSyncState, ZwlrOutputHeadV1}; |
| @@ -22,6 +23,7 @@ use zwlr_output_mode_v1::ZwlrOutputModeV1; | ||
| 22 | 23 | |
| 23 | 24 | use crate::backend::OutputId; |
| 24 | 25 | use crate::niri::State; |
| 26 | +use crate::protocols::EmptyData; | |
| 25 | 27 | use crate::utils::ipc_transform_to_smithay; |
| 26 | 28 | |
| 27 | 29 | const VERSION: u32 = 4; |
| @@ -50,6 +52,10 @@ pub trait OutputManagementHandler { | ||
| 50 | 52 | fn apply_output_config(&mut self, config: niri_config::Outputs); |
| 51 | 53 | } |
| 52 | 54 | |
| 55 | +struct OutputConfigurationData { | |
| 56 | + serial: u32, | |
| 57 | +} | |
| 58 | + | |
| 53 | 59 | #[derive(Debug)] |
| 54 | 60 | enum OutputConfigurationState { |
| 55 | 61 | Ongoing(HashMap<OutputId, niri_config::Output>), |
| @@ -65,11 +71,6 @@ impl OutputManagementManagerState { | ||
| 65 | 71 | pub fn new<D, F>(display: &DisplayHandle, filter: F) -> Self |
| 66 | 72 | where |
| 67 | 73 | D: GlobalDispatch<ZwlrOutputManagerV1, OutputManagementManagerGlobalData>, |
| 68 | - D: Dispatch<ZwlrOutputManagerV1, ()>, | |
| 69 | - D: Dispatch<ZwlrOutputHeadV1, OutputId>, | |
| 70 | - D: Dispatch<ZwlrOutputConfigurationV1, u32>, | |
| 71 | - D: Dispatch<ZwlrOutputConfigurationHeadV1, OutputConfigurationHeadState>, | |
| 72 | - D: Dispatch<ZwlrOutputModeV1, ()>, | |
| 73 | 74 | D: OutputManagementHandler, |
| 74 | 75 | D: 'static, |
| 75 | 76 | F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, |
| @@ -136,7 +137,7 @@ impl OutputManagementManagerState { | ||
| 136 | 137 | .create_resource::<ZwlrOutputModeV1, _, State>( |
| 137 | 138 | &self.display, |
| 138 | 139 | head.version(), |
| 139 | - (), | |
| 140 | + EmptyData, | |
| 140 | 141 | ) |
| 141 | 142 | .unwrap(); |
| 142 | 143 | head.mode(&new_mode); |
| @@ -269,27 +270,23 @@ impl OutputManagementManagerState { | ||
| 269 | 270 | } |
| 270 | 271 | } |
| 271 | 272 | |
| 272 | -impl<D> GlobalDispatch<ZwlrOutputManagerV1, OutputManagementManagerGlobalData, D> | |
| 273 | - for OutputManagementManagerState | |
| 273 | +impl<D> GlobalDispatch2<ZwlrOutputManagerV1, D> for OutputManagementManagerGlobalData | |
| 274 | 274 | where |
| 275 | - D: GlobalDispatch<ZwlrOutputManagerV1, OutputManagementManagerGlobalData>, | |
| 276 | - D: Dispatch<ZwlrOutputManagerV1, ()>, | |
| 275 | + D: Dispatch<ZwlrOutputManagerV1, EmptyData>, | |
| 276 | + D: Dispatch<ZwlrOutputModeV1, EmptyData>, | |
| 277 | 277 | D: Dispatch<ZwlrOutputHeadV1, OutputId>, |
| 278 | - D: Dispatch<ZwlrOutputConfigurationV1, u32>, | |
| 279 | - D: Dispatch<ZwlrOutputConfigurationHeadV1, OutputConfigurationHeadState>, | |
| 280 | - D: Dispatch<ZwlrOutputModeV1, ()>, | |
| 281 | 278 | D: OutputManagementHandler, |
| 282 | 279 | D: 'static, |
| 283 | 280 | { |
| 284 | 281 | fn bind( |
| 282 | + &self, | |
| 285 | 283 | state: &mut D, |
| 286 | 284 | display: &DisplayHandle, |
| 287 | 285 | client: &Client, |
| 288 | 286 | manager: New<ZwlrOutputManagerV1>, |
| 289 | - _manager_state: &OutputManagementManagerGlobalData, | |
| 290 | 287 | data_init: &mut DataInit<'_, D>, |
| 291 | 288 | ) { |
| 292 | - let manager = data_init.init(manager, ()); | |
| 289 | + let manager = data_init.init(manager, EmptyData); | |
| 293 | 290 | let g_state = state.output_management_state(); |
| 294 | 291 | let mut client_data = ClientData { |
| 295 | 292 | heads: HashMap::new(), |
| @@ -303,35 +300,30 @@ where | ||
| 303 | 300 | manager.done(g_state.serial); |
| 304 | 301 | } |
| 305 | 302 | |
| 306 | - fn can_view(client: Client, global_data: &OutputManagementManagerGlobalData) -> bool { | |
| 307 | - (global_data.filter)(&client) | |
| 303 | + fn can_view(&self, client: &Client) -> bool { | |
| 304 | + (self.filter)(client) | |
| 308 | 305 | } |
| 309 | 306 | } |
| 310 | 307 | |
| 311 | -impl<D> Dispatch<ZwlrOutputManagerV1, (), D> for OutputManagementManagerState | |
| 308 | +impl<D> Dispatch2<ZwlrOutputManagerV1, D> for EmptyData | |
| 312 | 309 | where |
| 313 | - D: GlobalDispatch<ZwlrOutputManagerV1, OutputManagementManagerGlobalData>, | |
| 314 | - D: Dispatch<ZwlrOutputManagerV1, ()>, | |
| 315 | - D: Dispatch<ZwlrOutputHeadV1, OutputId>, | |
| 316 | - D: Dispatch<ZwlrOutputConfigurationV1, u32>, | |
| 317 | - D: Dispatch<ZwlrOutputConfigurationHeadV1, OutputConfigurationHeadState>, | |
| 318 | - D: Dispatch<ZwlrOutputModeV1, ()>, | |
| 310 | + D: Dispatch<ZwlrOutputConfigurationV1, OutputConfigurationData>, | |
| 319 | 311 | D: OutputManagementHandler, |
| 320 | 312 | D: 'static, |
| 321 | 313 | { |
| 322 | 314 | fn request( |
| 315 | + &self, | |
| 323 | 316 | state: &mut D, |
| 324 | 317 | client: &Client, |
| 325 | 318 | _manager: &ZwlrOutputManagerV1, |
| 326 | 319 | request: zwlr_output_manager_v1::Request, |
| 327 | - _data: &(), | |
| 328 | 320 | _display: &DisplayHandle, |
| 329 | 321 | data_init: &mut DataInit<'_, D>, |
| 330 | 322 | ) { |
| 331 | 323 | match request { |
| 332 | 324 | zwlr_output_manager_v1::Request::CreateConfiguration { id, serial } => { |
| 333 | 325 | let g_state = state.output_management_state(); |
| 334 | - let conf = data_init.init(id, serial); | |
| 326 | + let conf = data_init.init(id, OutputConfigurationData { serial }); | |
| 335 | 327 | if let Some(client_data) = g_state.clients.get_mut(&client.id()) { |
| 336 | 328 | if serial != g_state.serial { |
| 337 | 329 | conf.cancelled(); |
| @@ -350,33 +342,28 @@ where | ||
| 350 | 342 | _ => unreachable!(), |
| 351 | 343 | } |
| 352 | 344 | } |
| 353 | - fn destroyed(state: &mut D, client: ClientId, _resource: &ZwlrOutputManagerV1, _data: &()) { | |
| 345 | + fn destroyed(&self, state: &mut D, client: ClientId, _resource: &ZwlrOutputManagerV1) { | |
| 354 | 346 | state.output_management_state().clients.remove(&client); |
| 355 | 347 | } |
| 356 | 348 | } |
| 357 | 349 | |
| 358 | -impl<D> Dispatch<ZwlrOutputConfigurationV1, u32, D> for OutputManagementManagerState | |
| 350 | +impl<D> Dispatch2<ZwlrOutputConfigurationV1, D> for OutputConfigurationData | |
| 359 | 351 | where |
| 360 | - D: GlobalDispatch<ZwlrOutputManagerV1, OutputManagementManagerGlobalData>, | |
| 361 | - D: Dispatch<ZwlrOutputManagerV1, ()>, | |
| 362 | - D: Dispatch<ZwlrOutputHeadV1, OutputId>, | |
| 363 | - D: Dispatch<ZwlrOutputConfigurationV1, u32>, | |
| 364 | 352 | D: Dispatch<ZwlrOutputConfigurationHeadV1, OutputConfigurationHeadState>, |
| 365 | - D: Dispatch<ZwlrOutputModeV1, ()>, | |
| 366 | 353 | D: OutputManagementHandler, |
| 367 | 354 | D: 'static, |
| 368 | 355 | { |
| 369 | 356 | fn request( |
| 357 | + &self, | |
| 370 | 358 | state: &mut D, |
| 371 | 359 | client: &Client, |
| 372 | 360 | conf: &ZwlrOutputConfigurationV1, |
| 373 | 361 | request: zwlr_output_configuration_v1::Request, |
| 374 | - serial: &u32, | |
| 375 | 362 | _display: &DisplayHandle, |
| 376 | 363 | data_init: &mut DataInit<'_, D>, |
| 377 | 364 | ) { |
| 378 | 365 | let g_state = state.output_management_state(); |
| 379 | - let outdated = *serial != g_state.serial; | |
| 366 | + let outdated = self.serial != g_state.serial; | |
| 380 | 367 | if outdated { |
| 381 | 368 | debug!("OutputConfiguration: request from an outdated configuration"); |
| 382 | 369 | } |
| @@ -565,24 +552,17 @@ where | ||
| 565 | 552 | } |
| 566 | 553 | } |
| 567 | 554 | |
| 568 | -impl<D> Dispatch<ZwlrOutputConfigurationHeadV1, OutputConfigurationHeadState, D> | |
| 569 | - for OutputManagementManagerState | |
| 555 | +impl<D> Dispatch2<ZwlrOutputConfigurationHeadV1, D> for OutputConfigurationHeadState | |
| 570 | 556 | where |
| 571 | - D: GlobalDispatch<ZwlrOutputManagerV1, OutputManagementManagerGlobalData>, | |
| 572 | - D: Dispatch<ZwlrOutputManagerV1, ()>, | |
| 573 | - D: Dispatch<ZwlrOutputHeadV1, OutputId>, | |
| 574 | - D: Dispatch<ZwlrOutputConfigurationV1, u32>, | |
| 575 | - D: Dispatch<ZwlrOutputConfigurationHeadV1, OutputConfigurationHeadState>, | |
| 576 | - D: Dispatch<ZwlrOutputModeV1, ()>, | |
| 577 | 557 | D: OutputManagementHandler, |
| 578 | 558 | D: 'static, |
| 579 | 559 | { |
| 580 | 560 | fn request( |
| 561 | + &self, | |
| 581 | 562 | state: &mut D, |
| 582 | 563 | client: &Client, |
| 583 | 564 | conf_head: &ZwlrOutputConfigurationHeadV1, |
| 584 | 565 | request: zwlr_output_configuration_head_v1::Request, |
| 585 | - data: &OutputConfigurationHeadState, | |
| 586 | 566 | _display: &DisplayHandle, |
| 587 | 567 | _data_init: &mut DataInit<'_, D>, |
| 588 | 568 | ) { |
| @@ -591,11 +571,12 @@ where | ||
| 591 | 571 | error!("ConfigurationHead: missing client data"); |
| 592 | 572 | return; |
| 593 | 573 | }; |
| 594 | - let OutputConfigurationHeadState::Ok(output_id, conf) = data else { | |
| 574 | + let OutputConfigurationHeadState::Ok(output_id, conf) = self else { | |
| 595 | 575 | warn!("ConfigurationHead: request sent to a cancelled head"); |
| 596 | 576 | return; |
| 597 | 577 | }; |
| 598 | - let Some(serial) = conf.data::<u32>() else { | |
| 578 | + let Some(OutputConfigurationData { serial }) = conf.data::<OutputConfigurationData>() | |
| 579 | + else { | |
| 599 | 580 | error!("ConfigurationHead: missing serial"); |
| 600 | 581 | return; |
| 601 | 582 | }; |
| @@ -740,23 +721,17 @@ where | ||
| 740 | 721 | } |
| 741 | 722 | } |
| 742 | 723 | |
| 743 | -impl<D> Dispatch<ZwlrOutputHeadV1, OutputId, D> for OutputManagementManagerState | |
| 724 | +impl<D> Dispatch2<ZwlrOutputHeadV1, D> for OutputId | |
| 744 | 725 | where |
| 745 | - D: GlobalDispatch<ZwlrOutputManagerV1, OutputManagementManagerGlobalData>, | |
| 746 | - D: Dispatch<ZwlrOutputManagerV1, ()>, | |
| 747 | - D: Dispatch<ZwlrOutputHeadV1, OutputId>, | |
| 748 | - D: Dispatch<ZwlrOutputConfigurationV1, u32>, | |
| 749 | - D: Dispatch<ZwlrOutputConfigurationHeadV1, OutputConfigurationHeadState>, | |
| 750 | - D: Dispatch<ZwlrOutputModeV1, ()>, | |
| 751 | 726 | D: OutputManagementHandler, |
| 752 | 727 | D: 'static, |
| 753 | 728 | { |
| 754 | 729 | fn request( |
| 730 | + &self, | |
| 755 | 731 | _state: &mut D, |
| 756 | 732 | _client: &Client, |
| 757 | 733 | _output_head: &ZwlrOutputHeadV1, |
| 758 | 734 | request: zwlr_output_head_v1::Request, |
| 759 | - _data: &OutputId, | |
| 760 | 735 | _display: &DisplayHandle, |
| 761 | 736 | _data_init: &mut DataInit<'_, D>, |
| 762 | 737 | ) { |
| @@ -765,30 +740,24 @@ where | ||
| 765 | 740 | _ => unreachable!(), |
| 766 | 741 | } |
| 767 | 742 | } |
| 768 | - fn destroyed(state: &mut D, client: ClientId, _resource: &ZwlrOutputHeadV1, data: &OutputId) { | |
| 743 | + fn destroyed(&self, state: &mut D, client: ClientId, _resource: &ZwlrOutputHeadV1) { | |
| 769 | 744 | if let Some(c) = state.output_management_state().clients.get_mut(&client) { |
| 770 | - c.heads.remove(data); | |
| 745 | + c.heads.remove(self); | |
| 771 | 746 | } |
| 772 | 747 | } |
| 773 | 748 | } |
| 774 | 749 | |
| 775 | -impl<D> Dispatch<ZwlrOutputModeV1, (), D> for OutputManagementManagerState | |
| 750 | +impl<D> Dispatch2<ZwlrOutputModeV1, D> for EmptyData | |
| 776 | 751 | where |
| 777 | - D: GlobalDispatch<ZwlrOutputManagerV1, OutputManagementManagerGlobalData>, | |
| 778 | - D: Dispatch<ZwlrOutputManagerV1, ()>, | |
| 779 | - D: Dispatch<ZwlrOutputHeadV1, OutputId>, | |
| 780 | - D: Dispatch<ZwlrOutputConfigurationV1, u32>, | |
| 781 | - D: Dispatch<ZwlrOutputConfigurationHeadV1, OutputConfigurationHeadState>, | |
| 782 | - D: Dispatch<ZwlrOutputModeV1, ()>, | |
| 783 | 752 | D: OutputManagementHandler, |
| 784 | 753 | D: 'static, |
| 785 | 754 | { |
| 786 | 755 | fn request( |
| 756 | + &self, | |
| 787 | 757 | _state: &mut D, |
| 788 | 758 | _client: &Client, |
| 789 | 759 | _mode: &ZwlrOutputModeV1, |
| 790 | 760 | request: zwlr_output_mode_v1::Request, |
| 791 | - _data: &(), | |
| 792 | 761 | _display: &DisplayHandle, |
| 793 | 762 | _data_init: &mut DataInit<'_, D>, |
| 794 | 763 | ) { |
| @@ -799,30 +768,6 @@ where | ||
| 799 | 768 | } |
| 800 | 769 | } |
| 801 | 770 | |
| 802 | -#[macro_export] | |
| 803 | -macro_rules! delegate_output_management{ | |
| 804 | - ($(@<$( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+>)? $ty: ty) => { | |
| 805 | - smithay::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 806 | - smithay::reexports::wayland_protocols_wlr::output_management::v1::server::zwlr_output_manager_v1::ZwlrOutputManagerV1: $crate::protocols::output_management::OutputManagementManagerGlobalData | |
| 807 | - ] => $crate::protocols::output_management::OutputManagementManagerState); | |
| 808 | - smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 809 | - smithay::reexports::wayland_protocols_wlr::output_management::v1::server::zwlr_output_manager_v1::ZwlrOutputManagerV1: () | |
| 810 | - ] => $crate::protocols::output_management::OutputManagementManagerState); | |
| 811 | - smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 812 | - smithay::reexports::wayland_protocols_wlr::output_management::v1::server::zwlr_output_configuration_v1::ZwlrOutputConfigurationV1: u32 | |
| 813 | - ] => $crate::protocols::output_management::OutputManagementManagerState); | |
| 814 | - smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 815 | - smithay::reexports::wayland_protocols_wlr::output_management::v1::server::zwlr_output_head_v1::ZwlrOutputHeadV1: $crate::backend::OutputId | |
| 816 | - ] => $crate::protocols::output_management::OutputManagementManagerState); | |
| 817 | - smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 818 | - smithay::reexports::wayland_protocols_wlr::output_management::v1::server::zwlr_output_mode_v1::ZwlrOutputModeV1: () | |
| 819 | - ] => $crate::protocols::output_management::OutputManagementManagerState); | |
| 820 | - smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 821 | - smithay::reexports::wayland_protocols_wlr::output_management::v1::server::zwlr_output_configuration_head_v1::ZwlrOutputConfigurationHeadV1: $crate::protocols::output_management::OutputConfigurationHeadState | |
| 822 | - ] => $crate::protocols::output_management::OutputManagementManagerState); | |
| 823 | - }; | |
| 824 | -} | |
| 825 | - | |
| 826 | 771 | fn notify_removed_head(clients: &mut HashMap<ClientId, ClientData>, head: &OutputId) { |
| 827 | 772 | for data in clients.values_mut() { |
| 828 | 773 | if let Some((head, mods)) = data.heads.remove(head) { |
| @@ -853,15 +798,9 @@ fn send_new_head<D>( | ||
| 853 | 798 | output: OutputId, |
| 854 | 799 | conf: &niri_ipc::Output, |
| 855 | 800 | ) where |
| 856 | - D: GlobalDispatch<ZwlrOutputManagerV1, OutputManagementManagerGlobalData>, | |
| 857 | - D: Dispatch<ZwlrOutputManagerV1, ()>, | |
| 858 | - D: Dispatch<ZwlrOutputConfigurationV1, u32>, | |
| 859 | - D: Dispatch<ZwlrOutputConfigurationHeadV1, OutputConfigurationHeadState>, | |
| 860 | - D: Dispatch<ZwlrOutputModeV1, ()>, | |
| 861 | - D: OutputManagementHandler, | |
| 862 | - D: 'static, | |
| 801 | + D: Dispatch<ZwlrOutputModeV1, EmptyData>, | |
| 863 | 802 | D: Dispatch<ZwlrOutputHeadV1, OutputId>, |
| 864 | - D: Dispatch<ZwlrOutputModeV1, ()>, | |
| 803 | + D: OutputManagementHandler, | |
| 865 | 804 | D: 'static, |
| 866 | 805 | { |
| 867 | 806 | let new_head = client |
| @@ -879,7 +818,7 @@ fn send_new_head<D>( | ||
| 879 | 818 | let mut new_modes = Vec::with_capacity(conf.modes.len()); |
| 880 | 819 | for (index, mode) in conf.modes.iter().enumerate() { |
| 881 | 820 | let new_mode = client |
| 882 | - .create_resource::<ZwlrOutputModeV1, _, D>(display, new_head.version(), ()) | |
| 821 | + .create_resource::<ZwlrOutputModeV1, _, D>(display, new_head.version(), EmptyData) | |
| 883 | 822 | .unwrap(); |
| 884 | 823 | new_head.mode(&new_mode); |
| 885 | 824 | new_mode.size(i32::from(mode.width), i32::from(mode.height)); |
src/protocols/screencopy.rsmodified+16 -41
| @@ -19,11 +19,12 @@ use smithay::reexports::wayland_server::{ | ||
| 19 | 19 | Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, |
| 20 | 20 | }; |
| 21 | 21 | use smithay::utils::{Physical, Point, Rectangle, Size, Transform}; |
| 22 | -use smithay::wayland::{dmabuf, shm}; | |
| 22 | +use smithay::wayland::{dmabuf, shm, Dispatch2, GlobalDispatch2}; | |
| 23 | 23 | use wayland_backend::server::Credentials; |
| 24 | 24 | use zwlr_screencopy_frame_v1::{Flags, ZwlrScreencopyFrameV1}; |
| 25 | 25 | use zwlr_screencopy_manager_v1::ZwlrScreencopyManagerV1; |
| 26 | 26 | |
| 27 | +use crate::protocols::EmptyData; | |
| 27 | 28 | use crate::utils::{get_credentials_for_client, get_monotonic_time, CastSessionId, CastStreamId}; |
| 28 | 29 | |
| 29 | 30 | const VERSION: u32 = 3; |
| @@ -211,8 +212,6 @@ impl ScreencopyManagerState { | ||
| 211 | 212 | pub fn new<D, F>(display: &DisplayHandle, filter: F) -> Self |
| 212 | 213 | where |
| 213 | 214 | D: GlobalDispatch<ZwlrScreencopyManagerV1, ScreencopyManagerGlobalData>, |
| 214 | - D: Dispatch<ZwlrScreencopyManagerV1, ()>, | |
| 215 | - D: Dispatch<ZwlrScreencopyFrameV1, ScreencopyFrameState>, | |
| 216 | 215 | D: ScreencopyHandler, |
| 217 | 216 | D: 'static, |
| 218 | 217 | F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, |
| @@ -278,24 +277,21 @@ impl ScreencopyManagerState { | ||
| 278 | 277 | } |
| 279 | 278 | } |
| 280 | 279 | |
| 281 | -impl<D> GlobalDispatch<ZwlrScreencopyManagerV1, ScreencopyManagerGlobalData, D> | |
| 282 | - for ScreencopyManagerState | |
| 280 | +impl<D> GlobalDispatch2<ZwlrScreencopyManagerV1, D> for ScreencopyManagerGlobalData | |
| 283 | 281 | where |
| 284 | - D: GlobalDispatch<ZwlrScreencopyManagerV1, ScreencopyManagerGlobalData>, | |
| 285 | - D: Dispatch<ZwlrScreencopyManagerV1, ()>, | |
| 286 | - D: Dispatch<ZwlrScreencopyFrameV1, ScreencopyFrameState>, | |
| 282 | + D: Dispatch<ZwlrScreencopyManagerV1, EmptyData>, | |
| 287 | 283 | D: ScreencopyHandler, |
| 288 | 284 | D: 'static, |
| 289 | 285 | { |
| 290 | 286 | fn bind( |
| 287 | + &self, | |
| 291 | 288 | state: &mut D, |
| 292 | 289 | dh: &DisplayHandle, |
| 293 | 290 | client: &Client, |
| 294 | 291 | manager: New<ZwlrScreencopyManagerV1>, |
| 295 | - _manager_state: &ScreencopyManagerGlobalData, | |
| 296 | 292 | data_init: &mut DataInit<'_, D>, |
| 297 | 293 | ) { |
| 298 | - let manager = data_init.init(manager, ()); | |
| 294 | + let manager = data_init.init(manager, EmptyData); | |
| 299 | 295 | |
| 300 | 296 | let state = state.screencopy_state(); |
| 301 | 297 | let credentials = get_credentials_for_client(dh, client); |
| @@ -303,25 +299,23 @@ where | ||
| 303 | 299 | state.queues.insert(manager.clone(), queue); |
| 304 | 300 | } |
| 305 | 301 | |
| 306 | - fn can_view(client: Client, global_data: &ScreencopyManagerGlobalData) -> bool { | |
| 307 | - (global_data.filter)(&client) | |
| 302 | + fn can_view(&self, client: &Client) -> bool { | |
| 303 | + (self.filter)(client) | |
| 308 | 304 | } |
| 309 | 305 | } |
| 310 | 306 | |
| 311 | -impl<D> Dispatch<ZwlrScreencopyManagerV1, (), D> for ScreencopyManagerState | |
| 307 | +impl<D> Dispatch2<ZwlrScreencopyManagerV1, D> for EmptyData | |
| 312 | 308 | where |
| 313 | - D: GlobalDispatch<ZwlrScreencopyManagerV1, ScreencopyManagerGlobalData>, | |
| 314 | - D: Dispatch<ZwlrScreencopyManagerV1, ()>, | |
| 315 | 309 | D: Dispatch<ZwlrScreencopyFrameV1, ScreencopyFrameState>, |
| 316 | 310 | D: ScreencopyHandler, |
| 317 | 311 | D: 'static, |
| 318 | 312 | { |
| 319 | 313 | fn request( |
| 314 | + &self, | |
| 320 | 315 | state: &mut D, |
| 321 | 316 | _client: &Client, |
| 322 | 317 | manager: &ZwlrScreencopyManagerV1, |
| 323 | 318 | request: zwlr_screencopy_manager_v1::Request, |
| 324 | - _data: &(), | |
| 325 | 319 | _display: &DisplayHandle, |
| 326 | 320 | data_init: &mut DataInit<'_, D>, |
| 327 | 321 | ) { |
| @@ -443,10 +437,10 @@ where | ||
| 443 | 437 | } |
| 444 | 438 | |
| 445 | 439 | fn destroyed( |
| 440 | + &self, | |
| 446 | 441 | state: &mut D, |
| 447 | 442 | _client: wayland_backend::server::ClientId, |
| 448 | 443 | manager: &ZwlrScreencopyManagerV1, |
| 449 | - _data: &(), | |
| 450 | 444 | ) { |
| 451 | 445 | let state = state.screencopy_state(); |
| 452 | 446 | |
| @@ -483,24 +477,6 @@ pub trait ScreencopyHandler { | ||
| 483 | 477 | fn screencopy_state(&mut self) -> &mut ScreencopyManagerState; |
| 484 | 478 | } |
| 485 | 479 | |
| 486 | -#[allow(missing_docs)] | |
| 487 | -#[macro_export] | |
| 488 | -macro_rules! delegate_screencopy { | |
| 489 | - ($(@<$( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+>)? $ty: ty) => { | |
| 490 | - smithay::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 491 | - smithay::reexports::wayland_protocols_wlr::screencopy::v1::server::zwlr_screencopy_manager_v1::ZwlrScreencopyManagerV1: $crate::protocols::screencopy::ScreencopyManagerGlobalData | |
| 492 | - ] => $crate::protocols::screencopy::ScreencopyManagerState); | |
| 493 | - | |
| 494 | - smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 495 | - smithay::reexports::wayland_protocols_wlr::screencopy::v1::server::zwlr_screencopy_manager_v1::ZwlrScreencopyManagerV1: () | |
| 496 | - ] => $crate::protocols::screencopy::ScreencopyManagerState); | |
| 497 | - | |
| 498 | - smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 499 | - smithay::reexports::wayland_protocols_wlr::screencopy::v1::server::zwlr_screencopy_frame_v1::ZwlrScreencopyFrameV1: $crate::protocols::screencopy::ScreencopyFrameState | |
| 500 | - ] => $crate::protocols::screencopy::ScreencopyManagerState); | |
| 501 | - }; | |
| 502 | -} | |
| 503 | - | |
| 504 | 480 | #[derive(Clone)] |
| 505 | 481 | pub struct ScreencopyFrameInfo { |
| 506 | 482 | output: Output, |
| @@ -518,18 +494,17 @@ pub enum ScreencopyFrameState { | ||
| 518 | 494 | }, |
| 519 | 495 | } |
| 520 | 496 | |
| 521 | -impl<D> Dispatch<ZwlrScreencopyFrameV1, ScreencopyFrameState, D> for ScreencopyManagerState | |
| 497 | +impl<D> Dispatch2<ZwlrScreencopyFrameV1, D> for ScreencopyFrameState | |
| 522 | 498 | where |
| 523 | - D: Dispatch<ZwlrScreencopyFrameV1, ScreencopyFrameState>, | |
| 524 | 499 | D: ScreencopyHandler, |
| 525 | 500 | D: 'static, |
| 526 | 501 | { |
| 527 | 502 | fn request( |
| 503 | + &self, | |
| 528 | 504 | state: &mut D, |
| 529 | 505 | _client: &Client, |
| 530 | 506 | frame: &ZwlrScreencopyFrameV1, |
| 531 | 507 | request: zwlr_screencopy_frame_v1::Request, |
| 532 | - data: &ScreencopyFrameState, | |
| 533 | 508 | _display: &DisplayHandle, |
| 534 | 509 | _data_init: &mut DataInit<'_, D>, |
| 535 | 510 | ) { |
| @@ -541,7 +516,7 @@ where | ||
| 541 | 516 | manager, |
| 542 | 517 | info, |
| 543 | 518 | copied, |
| 544 | - } = data | |
| 519 | + } = self | |
| 545 | 520 | else { |
| 546 | 521 | return; |
| 547 | 522 | }; |
| @@ -617,12 +592,12 @@ where | ||
| 617 | 592 | } |
| 618 | 593 | |
| 619 | 594 | fn destroyed( |
| 595 | + &self, | |
| 620 | 596 | state: &mut D, |
| 621 | 597 | _client: wayland_backend::server::ClientId, |
| 622 | 598 | frame: &ZwlrScreencopyFrameV1, |
| 623 | - data: &ScreencopyFrameState, | |
| 624 | 599 | ) { |
| 625 | - let ScreencopyFrameState::Pending { manager, .. } = data else { | |
| 600 | + let ScreencopyFrameState::Pending { manager, .. } = self else { | |
| 626 | 601 | return; |
| 627 | 602 | }; |
| 628 | 603 |
src/protocols/virtual_pointer.rsmodified+14 -36
| @@ -14,6 +14,7 @@ use smithay::reexports::wayland_server::protocol::wl_seat::WlSeat; | ||
| 14 | 14 | use smithay::reexports::wayland_server::{ |
| 15 | 15 | Client, DataInit, Dispatch, DisplayHandle, GlobalDispatch, New, Resource, |
| 16 | 16 | }; |
| 17 | +use smithay::wayland::{Dispatch2, GlobalDispatch2}; | |
| 17 | 18 | use wayland_backend::protocol::WEnum; |
| 18 | 19 | use wayland_protocols_wlr::virtual_pointer::v1::server::{ |
| 19 | 20 | zwlr_virtual_pointer_manager_v1, zwlr_virtual_pointer_v1, |
| @@ -21,6 +22,8 @@ use wayland_protocols_wlr::virtual_pointer::v1::server::{ | ||
| 21 | 22 | use zwlr_virtual_pointer_manager_v1::ZwlrVirtualPointerManagerV1; |
| 22 | 23 | use zwlr_virtual_pointer_v1::ZwlrVirtualPointerV1; |
| 23 | 24 | |
| 25 | +use crate::protocols::EmptyData; | |
| 26 | + | |
| 24 | 27 | const VERSION: u32 = 2; |
| 25 | 28 | |
| 26 | 29 | pub struct VirtualPointerManagerState { |
| @@ -289,8 +292,6 @@ impl VirtualPointerManagerState { | ||
| 289 | 292 | pub fn new<D, F>(display: &DisplayHandle, filter: F) -> Self |
| 290 | 293 | where |
| 291 | 294 | D: GlobalDispatch<ZwlrVirtualPointerManagerV1, VirtualPointerManagerGlobalData>, |
| 292 | - D: Dispatch<ZwlrVirtualPointerManagerV1, ()>, | |
| 293 | - D: Dispatch<ZwlrVirtualPointerV1, VirtualPointerUserData>, | |
| 294 | 295 | D: VirtualPointerHandler, |
| 295 | 296 | D: 'static, |
| 296 | 297 | F: for<'c> Fn(&'c Client) -> bool + Send + Sync + 'static, |
| @@ -306,44 +307,39 @@ impl VirtualPointerManagerState { | ||
| 306 | 307 | } |
| 307 | 308 | } |
| 308 | 309 | |
| 309 | -impl<D> GlobalDispatch<ZwlrVirtualPointerManagerV1, VirtualPointerManagerGlobalData, D> | |
| 310 | - for VirtualPointerManagerState | |
| 310 | +impl<D> GlobalDispatch2<ZwlrVirtualPointerManagerV1, D> for VirtualPointerManagerGlobalData | |
| 311 | 311 | where |
| 312 | - D: GlobalDispatch<ZwlrVirtualPointerManagerV1, VirtualPointerManagerGlobalData>, | |
| 313 | - D: Dispatch<ZwlrVirtualPointerManagerV1, ()>, | |
| 314 | - D: Dispatch<ZwlrVirtualPointerV1, VirtualPointerUserData>, | |
| 315 | - D: VirtualPointerHandler, | |
| 312 | + D: Dispatch<ZwlrVirtualPointerManagerV1, EmptyData>, | |
| 316 | 313 | D: 'static, |
| 317 | 314 | { |
| 318 | 315 | fn bind( |
| 316 | + &self, | |
| 319 | 317 | _state: &mut D, |
| 320 | 318 | _handle: &DisplayHandle, |
| 321 | 319 | _client: &Client, |
| 322 | 320 | manager: New<ZwlrVirtualPointerManagerV1>, |
| 323 | - _manager_state: &VirtualPointerManagerGlobalData, | |
| 324 | 321 | data_init: &mut DataInit<'_, D>, |
| 325 | 322 | ) { |
| 326 | - data_init.init(manager, ()); | |
| 323 | + data_init.init(manager, EmptyData); | |
| 327 | 324 | } |
| 328 | 325 | |
| 329 | - fn can_view(client: Client, global_data: &VirtualPointerManagerGlobalData) -> bool { | |
| 330 | - (global_data.filter)(&client) | |
| 326 | + fn can_view(&self, client: &Client) -> bool { | |
| 327 | + (self.filter)(client) | |
| 331 | 328 | } |
| 332 | 329 | } |
| 333 | 330 | |
| 334 | -impl<D> Dispatch<ZwlrVirtualPointerManagerV1, (), D> for VirtualPointerManagerState | |
| 331 | +impl<D> Dispatch2<ZwlrVirtualPointerManagerV1, D> for EmptyData | |
| 335 | 332 | where |
| 336 | - D: Dispatch<ZwlrVirtualPointerManagerV1, ()>, | |
| 337 | 333 | D: Dispatch<ZwlrVirtualPointerV1, VirtualPointerUserData>, |
| 338 | 334 | D: VirtualPointerHandler, |
| 339 | 335 | D: 'static, |
| 340 | 336 | { |
| 341 | 337 | fn request( |
| 338 | + &self, | |
| 342 | 339 | state: &mut D, |
| 343 | 340 | _client: &Client, |
| 344 | 341 | _resource: &ZwlrVirtualPointerManagerV1, |
| 345 | 342 | request: <ZwlrVirtualPointerManagerV1 as Resource>::Request, |
| 346 | - _data: &(), | |
| 347 | 343 | _dhandle: &DisplayHandle, |
| 348 | 344 | data_init: &mut DataInit<'_, D>, |
| 349 | 345 | ) { |
| @@ -377,18 +373,17 @@ where | ||
| 377 | 373 | } |
| 378 | 374 | } |
| 379 | 375 | |
| 380 | -impl<D> Dispatch<ZwlrVirtualPointerV1, VirtualPointerUserData, D> for VirtualPointerManagerState | |
| 376 | +impl<D> Dispatch2<ZwlrVirtualPointerV1, D> for VirtualPointerUserData | |
| 381 | 377 | where |
| 382 | - D: Dispatch<ZwlrVirtualPointerV1, VirtualPointerUserData>, | |
| 383 | 378 | D: VirtualPointerHandler, |
| 384 | 379 | D: 'static, |
| 385 | 380 | { |
| 386 | 381 | fn request( |
| 382 | + &self, | |
| 387 | 383 | handler: &mut D, |
| 388 | 384 | _client: &Client, |
| 389 | 385 | resource: &ZwlrVirtualPointerV1, |
| 390 | 386 | request: <ZwlrVirtualPointerV1 as Resource>::Request, |
| 391 | - _data: &VirtualPointerUserData, | |
| 392 | 387 | _dhandle: &DisplayHandle, |
| 393 | 388 | _data_init: &mut DataInit<'_, D>, |
| 394 | 389 | ) { |
| @@ -528,10 +523,10 @@ where | ||
| 528 | 523 | } |
| 529 | 524 | |
| 530 | 525 | fn destroyed( |
| 526 | + &self, | |
| 531 | 527 | handler: &mut D, |
| 532 | 528 | _client: wayland_backend::server::ClientId, |
| 533 | 529 | resource: &ZwlrVirtualPointerV1, |
| 534 | - _data: &VirtualPointerUserData, | |
| 535 | 530 | ) { |
| 536 | 531 | let pointer = VirtualPointer { |
| 537 | 532 | pointer: resource.clone(), |
| @@ -544,20 +539,3 @@ where | ||
| 544 | 539 | .remove(resource); |
| 545 | 540 | } |
| 546 | 541 | } |
| 547 | - | |
| 548 | -#[macro_export] | |
| 549 | -macro_rules! delegate_virtual_pointer { | |
| 550 | - ($(@<$( $lt:tt $( : $clt:tt $(+ $dlt:tt )* )? ),+>)? $ty: ty) => { | |
| 551 | - smithay::reexports::wayland_server::delegate_global_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 552 | - smithay::reexports::wayland_protocols_wlr::virtual_pointer::v1::server::zwlr_virtual_pointer_manager_v1::ZwlrVirtualPointerManagerV1: $crate::protocols::virtual_pointer::VirtualPointerManagerGlobalData | |
| 553 | - ] => $crate::protocols::virtual_pointer::VirtualPointerManagerState); | |
| 554 | - | |
| 555 | - smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 556 | - smithay::reexports::wayland_protocols_wlr::virtual_pointer::v1::server::zwlr_virtual_pointer_manager_v1::ZwlrVirtualPointerManagerV1: () | |
| 557 | - ] => $crate::protocols::virtual_pointer::VirtualPointerManagerState); | |
| 558 | - | |
| 559 | - smithay::reexports::wayland_server::delegate_dispatch!($(@< $( $lt $( : $clt $(+ $dlt )* )? ),+ >)? $ty: [ | |
| 560 | - smithay::reexports::wayland_protocols_wlr::virtual_pointer::v1::server::zwlr_virtual_pointer_v1::ZwlrVirtualPointerV1: $crate::protocols::virtual_pointer::VirtualPointerUserData | |
| 561 | - ] => $crate::protocols::virtual_pointer::VirtualPointerManagerState); | |
| 562 | - }; | |
| 563 | -} |