wayland: allow binding to removed outputs
This commit is contained in:
parent
4651f760f0
commit
c27bf4d597
4 changed files with 89 additions and 5 deletions
|
|
@ -1,3 +1,5 @@
|
|||
mod removed_output;
|
||||
|
||||
use {
|
||||
crate::{
|
||||
backend,
|
||||
|
|
@ -229,13 +231,15 @@ impl WlOutputGlobal {
|
|||
|
||||
global_base!(WlOutputGlobal, WlOutput, WlOutputError);
|
||||
|
||||
const OUTPUT_VERSION: u32 = 4;
|
||||
|
||||
impl Global for WlOutputGlobal {
|
||||
fn singleton(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn version(&self) -> u32 {
|
||||
4
|
||||
OUTPUT_VERSION
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
|
|
|
|||
63
src/ifs/wl_output/removed_output.rs
Normal file
63
src/ifs/wl_output/removed_output.rs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
globals::{Global, GlobalName, RemovableWaylandGlobal},
|
||||
ifs::wl_output::{WlOutput, WlOutputGlobal, OUTPUT_VERSION},
|
||||
object::Version,
|
||||
wire::WlOutputId,
|
||||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
struct RemovedOutputGlobal {
|
||||
name: GlobalName,
|
||||
}
|
||||
|
||||
impl RemovedOutputGlobal {
|
||||
fn bind_(
|
||||
self: Rc<Self>,
|
||||
id: WlOutputId,
|
||||
client: &Rc<Client>,
|
||||
version: Version,
|
||||
) -> Result<(), RemovedOutputError> {
|
||||
let obj = Rc::new(WlOutput {
|
||||
global: Default::default(),
|
||||
id,
|
||||
xdg_outputs: Default::default(),
|
||||
client: client.clone(),
|
||||
version,
|
||||
tracker: Default::default(),
|
||||
});
|
||||
track!(client, obj);
|
||||
client.add_client_obj(&obj)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
global_base!(RemovedOutputGlobal, WlOutput, RemovedOutputError);
|
||||
|
||||
impl Global for RemovedOutputGlobal {
|
||||
fn singleton(&self) -> bool {
|
||||
false
|
||||
}
|
||||
|
||||
fn version(&self) -> u32 {
|
||||
OUTPUT_VERSION
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_global!(RemovedOutputGlobal);
|
||||
|
||||
impl RemovableWaylandGlobal for WlOutputGlobal {
|
||||
fn create_replacement(&self) -> Rc<dyn Global> {
|
||||
Rc::new(RemovedOutputGlobal { name: self.name })
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
enum RemovedOutputError {
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
}
|
||||
efrom!(RemovedOutputError, ClientError);
|
||||
Loading…
Add table
Add a link
Reference in a new issue