Use WeakOutput when accessing data of ZwlrOutputHeadV1

It seems cd9ff0b7bb broke mirroring.
Though it's also a bug that if any of these if conditions is not met,
the data will not be initialized.

Fixes https://github.com/pop-os/cosmic-epoch/issues/1341.
This commit is contained in:
Ian Douglas Scott 2024-12-10 14:25:15 -08:00 committed by Victoria Brekenfeld
parent 2c01c94477
commit fdfc5cbeb4
2 changed files with 6 additions and 4 deletions

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: GPL-3.0-only
use smithay::{
output::{Mode, Output},
output::Mode,
reexports::{
wayland_protocols_wlr::output_management::v1::server::{
zwlr_output_configuration_head_v1::{self, ZwlrOutputConfigurationHeadV1},
@ -179,7 +179,9 @@ where
} => {
if let Ok(obj) = obj.upgrade() {
if let Some(data) = obj.data::<PendingConfiguration>() {
if let Some(output) = mirroring.data::<Output>() {
if let Some(output) =
mirroring.data::<WeakOutput>().and_then(|x| x.upgrade())
{
let mut pending = data.lock().unwrap();
if pending.heads.iter().any(|(h, _)| *h == head) {
obj.post_error(
@ -195,7 +197,7 @@ where
if let Some(conf) = c.data::<PendingOutputConfiguration>() {
match conf.lock().unwrap().mirroring.as_ref() {
Some(mirrored) => {
head.data::<Output>().is_some_and(|o| o == mirrored) // we are already a mirror target -> invalid
head.data::<WeakOutput>().is_some_and(|o| o == mirrored) // we are already a mirror target -> invalid
|| *h == mirroring // our target already mirrors -> invalid
}
None => false,

View file

@ -234,7 +234,7 @@ where
if pending.heads.iter().any(|(_, c)| match c {
Some(conf) => {
if let Some(output_conf) = conf.data::<PendingOutputConfiguration>() {
if let Some(output) = head.data::<Output>() {
if let Some(output) = head.data::<WeakOutput>() {
let pending_conf = output_conf.lock().unwrap();
pending_conf.mirroring.as_ref().is_some_and(|o| o == output)
} else {