From 5e7c53252b74b42c76ae26fd4f0c4b8b956700d5 Mon Sep 17 00:00:00 2001 From: drendog Date: Wed, 26 Nov 2025 17:30:35 +0100 Subject: [PATCH] fix: check current output mode --- .../wayland/event_handling/app_dispatcher.rs | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/crates/adapters/src/wayland/event_handling/app_dispatcher.rs b/crates/adapters/src/wayland/event_handling/app_dispatcher.rs index edea1f2..ec6f60d 100644 --- a/crates/adapters/src/wayland/event_handling/app_dispatcher.rs +++ b/crates/adapters/src/wayland/event_handling/app_dispatcher.rs @@ -8,7 +8,7 @@ use smithay_client_toolkit::reexports::protocols_wlr::layer_shell::v1::client::{ zwlr_layer_surface_v1::{self, ZwlrLayerSurfaceV1}, }; use wayland_client::{ - Connection, Dispatch, Proxy, QueueHandle, + Connection, Dispatch, Proxy, QueueHandle, WEnum, globals::GlobalListContents, protocol::{ wl_compositor::WlCompositor, @@ -72,6 +72,7 @@ impl Dispatch for AppState { } impl Dispatch for AppState { + #[allow(clippy::cognitive_complexity)] fn event( state: &mut Self, proxy: &WlOutput, @@ -84,11 +85,27 @@ impl Dispatch for AppState { let handle = state.get_handle_by_output_id(&output_id); match event { - wl_output::Event::Mode { width, height, .. } => { - if let Some(window) = state.get_output_by_output_id_mut(&output_id) { - window.handle_output_mode(width, height); + wl_output::Event::Mode { + flags: WEnum::Value(mode_flags), + width, + height, + .. + } => { + let is_current = mode_flags.contains(wl_output::Mode::Current); + let is_preferred = mode_flags.contains(wl_output::Mode::Preferred); + info!( + "WlOutput mode: {}x{} (current: {}, preferred: {})", + width, height, is_current, is_preferred + ); + if is_current { + if let Some(window) = state.get_output_by_output_id_mut(&output_id) { + window.handle_output_mode(width, height); + } } } + wl_output::Event::Mode { .. } => { + debug!("WlOutput mode event with unknown flags value"); + } wl_output::Event::Description { ref description } => { info!("WlOutput description: {description:?}"); if let Some(handle) = handle {