From 5e5d64e89d07a14940080ddd9a66b8ab9662c7f1 Mon Sep 17 00:00:00 2001 From: galister <22305755+galister@users.noreply.github.com> Date: Thu, 17 Jul 2025 04:56:17 +0900 Subject: [PATCH] wayland: only consider current output mode --- wlx-capture/src/wayland.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/wlx-capture/src/wayland.rs b/wlx-capture/src/wayland.rs index 97f90f3a..66d45c02 100644 --- a/wlx-capture/src/wayland.rs +++ b/wlx-capture/src/wayland.rs @@ -19,15 +19,15 @@ use smithay_client_toolkit::reexports::{ pub use wayland_client; use wayland_client::{ + Connection, Dispatch, EventQueue, Proxy, QueueHandle, backend::WaylandError, - globals::{registry_queue_init, GlobalList, GlobalListContents}, + globals::{GlobalList, GlobalListContents, registry_queue_init}, protocol::{ wl_output::{self, Transform, WlOutput}, wl_registry::{self, WlRegistry}, wl_seat::WlSeat, wl_shm::WlShm, }, - Connection, Dispatch, EventQueue, Proxy, QueueHandle, }; pub enum OutputChangeEvent { @@ -291,7 +291,20 @@ impl Dispatch for WlxClient { _qhandle: &QueueHandle, ) { match event { - wl_output::Event::Mode { width, height, .. } => { + wl_output::Event::Mode { + width, + height, + flags, + .. + } => { + if !flags + .into_result() + .is_ok_and(|f| f.intersects(wl_output::Mode::Current)) + { + // https://github.com/galister/wlx-capture/issues/5 + return; + } + if let Some(output) = state.outputs.get_mut(*data) { output.size = (width, height); if output.done {