Step 4a + 4b combined. - src/state.rs (1594 LOC) -> src/state/mod.rs (struct + inherent methods + types + helpers; 999 LOC) + src/state/dispatch/ (13 Dispatch impls across 6 files: registry.rs / wl_output.rs / dmabuf.rs / screencopy.rs / output_mgr.rs / buffer.rs). Per Oracle audit: orphan rule permits Dispatch impls in submodules because Dispatch is a foreign trait on local type State<S>. All State fields the impls touch are already pub/pub(crate) — no visibility widening needed. Verification (all green): - cargo build / cargo build --release - cargo test (79 lib + 3 integration = 82 pass, 1 ignored — unchanged) - cargo clippy --all-targets -- -D warnings - cargo fmt --check - cargo check --bin vaapi_import_bench --bin sw_encode_bench
110 lines
3.7 KiB
Rust
110 lines
3.7 KiB
Rust
use wayland_client::{event_created_child, Dispatch, Proxy, QueueHandle};
|
|
use wayland_protocols::xdg::xdg_output::zv1::client::zxdg_output_manager_v1::ZxdgOutputManagerV1;
|
|
use wayland_protocols_wlr::output_management::v1::client::zwlr_output_head_v1::{
|
|
self, Event as WlrHeadEvent, ZwlrOutputHeadV1,
|
|
};
|
|
use wayland_protocols_wlr::output_management::v1::client::zwlr_output_manager_v1::{
|
|
self, Event as WlrOutputManagerEvent, ZwlrOutputManagerV1,
|
|
};
|
|
use wayland_protocols_wlr::output_management::v1::client::zwlr_output_mode_v1::ZwlrOutputModeV1;
|
|
|
|
use crate::state::{CaptureSource, EncConstructionStage, State, WlrHeadInfo};
|
|
|
|
impl<S: CaptureSource> Dispatch<ZxdgOutputManagerV1, ()> for State<S> {
|
|
fn event(
|
|
_state: &mut Self,
|
|
_proxy: &ZxdgOutputManagerV1,
|
|
_event: <ZxdgOutputManagerV1 as Proxy>::Event,
|
|
_data: &(),
|
|
_conn: &wayland_client::Connection,
|
|
_qhandle: &QueueHandle<State<S>>,
|
|
) {
|
|
}
|
|
}
|
|
|
|
impl<S: CaptureSource> Dispatch<ZwlrOutputManagerV1, ()> for State<S> {
|
|
fn event(
|
|
state: &mut Self,
|
|
_proxy: &ZwlrOutputManagerV1,
|
|
event: <ZwlrOutputManagerV1 as Proxy>::Event,
|
|
_data: &(),
|
|
_conn: &wayland_client::Connection,
|
|
_qhandle: &QueueHandle<State<S>>,
|
|
) {
|
|
match event {
|
|
WlrOutputManagerEvent::Head { head } => {
|
|
let _head: ZwlrOutputHeadV1 = head;
|
|
tracing::debug!("wlr output head advertised");
|
|
}
|
|
WlrOutputManagerEvent::Done { .. } => {
|
|
if let EncConstructionStage::ProbingOutputs {
|
|
wlr_manager_done,
|
|
outputs,
|
|
..
|
|
} = &mut state.stage
|
|
{
|
|
*wlr_manager_done = true;
|
|
let count = outputs.len();
|
|
for idx in 0..count {
|
|
state.try_finalize_output(idx);
|
|
}
|
|
}
|
|
}
|
|
WlrOutputManagerEvent::Finished => {
|
|
tracing::warn!("zwlr_output_manager_v1::Finished received during probing");
|
|
}
|
|
_ => {}
|
|
}
|
|
}
|
|
|
|
event_created_child!(State<S>, ZwlrOutputManagerV1, [
|
|
zwlr_output_manager_v1::EVT_HEAD_OPCODE => (ZwlrOutputHeadV1, ()),
|
|
]);
|
|
}
|
|
|
|
impl<S: CaptureSource> Dispatch<ZwlrOutputHeadV1, ()> for State<S> {
|
|
fn event(
|
|
state: &mut Self,
|
|
proxy: &ZwlrOutputHeadV1,
|
|
event: <ZwlrOutputHeadV1 as Proxy>::Event,
|
|
_data: &(),
|
|
_conn: &wayland_client::Connection,
|
|
_qhandle: &QueueHandle<State<S>>,
|
|
) {
|
|
match event {
|
|
WlrHeadEvent::Name { name } => {
|
|
if let EncConstructionStage::ProbingOutputs {
|
|
wlr_heads,
|
|
wlr_head_proxy_to_name,
|
|
..
|
|
} = &mut state.stage
|
|
{
|
|
wlr_heads.entry(name.clone()).or_insert(WlrHeadInfo {});
|
|
wlr_head_proxy_to_name.insert(proxy.id(), name);
|
|
}
|
|
}
|
|
WlrHeadEvent::Position { .. } => {}
|
|
WlrHeadEvent::Finished => {
|
|
tracing::debug!("zwlr_output_head_v1::Finished received");
|
|
}
|
|
_ => {}
|
|
}
|
|
}
|
|
|
|
event_created_child!(State<S>, ZwlrOutputHeadV1, [
|
|
zwlr_output_head_v1::EVT_MODE_OPCODE => (ZwlrOutputModeV1, ()),
|
|
]);
|
|
}
|
|
|
|
impl<S: CaptureSource> Dispatch<ZwlrOutputModeV1, ()> for State<S> {
|
|
fn event(
|
|
_state: &mut Self,
|
|
_proxy: &ZwlrOutputModeV1,
|
|
_event: <ZwlrOutputModeV1 as Proxy>::Event,
|
|
_data: &(),
|
|
_conn: &wayland_client::Connection,
|
|
_qhandle: &QueueHandle<State<S>>,
|
|
) {
|
|
}
|
|
}
|