mirror of
https://github.com/pinnacle-comp/pinnacle.git
synced 2024-12-26 21:58:10 +01:00
output-mgmt: Post error on config reuse
This commit is contained in:
parent
1c55296d8f
commit
a8562277c1
1 changed files with 49 additions and 6 deletions
|
@ -70,6 +70,7 @@ pub struct PendingOutputConfiguration {
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
struct PendingOutputConfigurationInner {
|
struct PendingOutputConfigurationInner {
|
||||||
cancelled: bool,
|
cancelled: bool,
|
||||||
|
used: bool,
|
||||||
pending_heads: HashMap<ZwlrOutputHeadV1, PendingHead>,
|
pending_heads: HashMap<ZwlrOutputHeadV1, PendingHead>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,6 +112,9 @@ pub struct OutputData {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OutputManagementManagerState {
|
impl OutputManagementManagerState {
|
||||||
|
/// Add this head.
|
||||||
|
///
|
||||||
|
/// [`OutputManagementManagerState::update`] needs to be called afterwards to apply the new state.
|
||||||
pub fn add_head<D>(&mut self, output: &Output)
|
pub fn add_head<D>(&mut self, output: &Output)
|
||||||
where
|
where
|
||||||
D: Dispatch<ZwlrOutputHeadV1, Output>
|
D: Dispatch<ZwlrOutputHeadV1, Output>
|
||||||
|
@ -145,12 +149,18 @@ impl OutputManagementManagerState {
|
||||||
self.outputs.insert(output.clone(), output_data);
|
self.outputs.insert(output.clone(), output_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Mark this head as removed.
|
||||||
|
///
|
||||||
|
/// [`OutputManagementManagerState::update`] needs to be called afterwards to apply the new state.
|
||||||
pub fn remove_head(&mut self, output: &Output) {
|
pub fn remove_head(&mut self, output: &Output) {
|
||||||
if self.outputs.remove(output).is_some() {
|
if self.outputs.remove(output).is_some() {
|
||||||
self.removed_outputs.insert(output.clone());
|
self.removed_outputs.insert(output.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Mark this head as enabled or not.
|
||||||
|
///
|
||||||
|
/// [`OutputManagementManagerState::update`] needs to be called afterwards to apply the new state.
|
||||||
pub fn set_head_enabled<D>(&mut self, output: &Output, enabled: bool)
|
pub fn set_head_enabled<D>(&mut self, output: &Output, enabled: bool)
|
||||||
where
|
where
|
||||||
D: Dispatch<ZwlrOutputHeadV1, Output>
|
D: Dispatch<ZwlrOutputHeadV1, Output>
|
||||||
|
@ -210,6 +220,9 @@ impl OutputManagementManagerState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Update output management state.
|
||||||
|
///
|
||||||
|
/// This needs to be called whenever output state changes to notify clients of the new state.
|
||||||
pub fn update<D>(&mut self)
|
pub fn update<D>(&mut self)
|
||||||
where
|
where
|
||||||
D: Dispatch<ZwlrOutputHeadV1, Output>
|
D: Dispatch<ZwlrOutputHeadV1, Output>
|
||||||
|
@ -386,12 +399,14 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO:
|
if head.version() >= zwlr_output_head_v1::EVT_ADAPTIVE_SYNC_SINCE {
|
||||||
// SINCE FOUR
|
// TODO:
|
||||||
// head.adaptive_sync(match data.adaptive_sync {
|
// head.adaptive_sync(match data.adaptive_sync {
|
||||||
// true => AdaptiveSyncState::Enabled,
|
// true => AdaptiveSyncState::Enabled,
|
||||||
// false => AdaptiveSyncState::Disabled,
|
// false => AdaptiveSyncState::Disabled,
|
||||||
// });
|
// });
|
||||||
|
head.adaptive_sync(AdaptiveSyncState::Disabled);
|
||||||
|
}
|
||||||
|
|
||||||
head.enabled(true as i32);
|
head.enabled(true as i32);
|
||||||
if let Some(current_mode) = output.current_mode() {
|
if let Some(current_mode) = output.current_mode() {
|
||||||
|
@ -561,6 +576,7 @@ where
|
||||||
serial,
|
serial,
|
||||||
inner: Mutex::new(PendingOutputConfigurationInner {
|
inner: Mutex::new(PendingOutputConfigurationInner {
|
||||||
cancelled: false,
|
cancelled: false,
|
||||||
|
used: false,
|
||||||
pending_heads: HashMap::new(),
|
pending_heads: HashMap::new(),
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
@ -581,6 +597,7 @@ where
|
||||||
serial,
|
serial,
|
||||||
inner: Mutex::new(PendingOutputConfigurationInner {
|
inner: Mutex::new(PendingOutputConfigurationInner {
|
||||||
cancelled: false,
|
cancelled: false,
|
||||||
|
used: false,
|
||||||
pending_heads,
|
pending_heads,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
@ -730,6 +747,14 @@ where
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if data.used {
|
||||||
|
resource.post_error(
|
||||||
|
zwlr_output_configuration_v1::Error::AlreadyUsed,
|
||||||
|
"configuration has already been applied or tested",
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let manager_serial =
|
let manager_serial =
|
||||||
manager_for_configuration(state, resource).map(|(_, data)| data.serial);
|
manager_for_configuration(state, resource).map(|(_, data)| data.serial);
|
||||||
|
|
||||||
|
@ -758,6 +783,14 @@ where
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if data.used {
|
||||||
|
resource.post_error(
|
||||||
|
zwlr_output_configuration_v1::Error::AlreadyUsed,
|
||||||
|
"configuration has already been applied or tested",
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let manager_serial =
|
let manager_serial =
|
||||||
manager_for_configuration(state, resource).map(|(_, data)| data.serial);
|
manager_for_configuration(state, resource).map(|(_, data)| data.serial);
|
||||||
|
|
||||||
|
@ -787,6 +820,14 @@ where
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if data.used {
|
||||||
|
resource.post_error(
|
||||||
|
zwlr_output_configuration_v1::Error::AlreadyUsed,
|
||||||
|
"configuration has already been applied or tested",
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let manager_serial =
|
let manager_serial =
|
||||||
manager_for_configuration(state, resource).map(|(_, data)| data.serial);
|
manager_for_configuration(state, resource).map(|(_, data)| data.serial);
|
||||||
|
|
||||||
|
@ -849,6 +890,8 @@ where
|
||||||
} else {
|
} else {
|
||||||
resource.failed();
|
resource.failed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data.used = true;
|
||||||
}
|
}
|
||||||
zwlr_output_configuration_v1::Request::Destroy => (),
|
zwlr_output_configuration_v1::Request::Destroy => (),
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
|
Loading…
Reference in a new issue