fix: check current output mode

This commit is contained in:
drendog 2025-11-26 17:30:35 +01:00
parent 1e21635233
commit 5e7c53252b
Signed by: dwenya
GPG key ID: 8DD77074645332D0

View file

@ -8,7 +8,7 @@ use smithay_client_toolkit::reexports::protocols_wlr::layer_shell::v1::client::{
zwlr_layer_surface_v1::{self, ZwlrLayerSurfaceV1}, zwlr_layer_surface_v1::{self, ZwlrLayerSurfaceV1},
}; };
use wayland_client::{ use wayland_client::{
Connection, Dispatch, Proxy, QueueHandle, Connection, Dispatch, Proxy, QueueHandle, WEnum,
globals::GlobalListContents, globals::GlobalListContents,
protocol::{ protocol::{
wl_compositor::WlCompositor, wl_compositor::WlCompositor,
@ -72,6 +72,7 @@ impl Dispatch<ZwlrLayerSurfaceV1, ()> for AppState {
} }
impl Dispatch<WlOutput, ()> for AppState { impl Dispatch<WlOutput, ()> for AppState {
#[allow(clippy::cognitive_complexity)]
fn event( fn event(
state: &mut Self, state: &mut Self,
proxy: &WlOutput, proxy: &WlOutput,
@ -84,11 +85,27 @@ impl Dispatch<WlOutput, ()> for AppState {
let handle = state.get_handle_by_output_id(&output_id); let handle = state.get_handle_by_output_id(&output_id);
match event { match event {
wl_output::Event::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) { if let Some(window) = state.get_output_by_output_id_mut(&output_id) {
window.handle_output_mode(width, height); window.handle_output_mode(width, height);
} }
} }
}
wl_output::Event::Mode { .. } => {
debug!("WlOutput mode event with unknown flags value");
}
wl_output::Event::Description { ref description } => { wl_output::Event::Description { ref description } => {
info!("WlOutput description: {description:?}"); info!("WlOutput description: {description:?}");
if let Some(handle) = handle { if let Some(handle) = handle {