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