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:
parent
2c01c94477
commit
fdfc5cbeb4
2 changed files with 6 additions and 4 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
// SPDX-License-Identifier: GPL-3.0-only
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
use smithay::{
|
use smithay::{
|
||||||
output::{Mode, Output},
|
output::Mode,
|
||||||
reexports::{
|
reexports::{
|
||||||
wayland_protocols_wlr::output_management::v1::server::{
|
wayland_protocols_wlr::output_management::v1::server::{
|
||||||
zwlr_output_configuration_head_v1::{self, ZwlrOutputConfigurationHeadV1},
|
zwlr_output_configuration_head_v1::{self, ZwlrOutputConfigurationHeadV1},
|
||||||
|
|
@ -179,7 +179,9 @@ where
|
||||||
} => {
|
} => {
|
||||||
if let Ok(obj) = obj.upgrade() {
|
if let Ok(obj) = obj.upgrade() {
|
||||||
if let Some(data) = obj.data::<PendingConfiguration>() {
|
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();
|
let mut pending = data.lock().unwrap();
|
||||||
if pending.heads.iter().any(|(h, _)| *h == head) {
|
if pending.heads.iter().any(|(h, _)| *h == head) {
|
||||||
obj.post_error(
|
obj.post_error(
|
||||||
|
|
@ -195,7 +197,7 @@ where
|
||||||
if let Some(conf) = c.data::<PendingOutputConfiguration>() {
|
if let Some(conf) = c.data::<PendingOutputConfiguration>() {
|
||||||
match conf.lock().unwrap().mirroring.as_ref() {
|
match conf.lock().unwrap().mirroring.as_ref() {
|
||||||
Some(mirrored) => {
|
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
|
|| *h == mirroring // our target already mirrors -> invalid
|
||||||
}
|
}
|
||||||
None => false,
|
None => false,
|
||||||
|
|
|
||||||
|
|
@ -234,7 +234,7 @@ where
|
||||||
if pending.heads.iter().any(|(_, c)| match c {
|
if pending.heads.iter().any(|(_, c)| match c {
|
||||||
Some(conf) => {
|
Some(conf) => {
|
||||||
if let Some(output_conf) = conf.data::<PendingOutputConfiguration>() {
|
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();
|
let pending_conf = output_conf.lock().unwrap();
|
||||||
pending_conf.mirroring.as_ref().is_some_and(|o| o == output)
|
pending_conf.mirroring.as_ref().is_some_and(|o| o == output)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue