autocommit 2022-04-17 17:59:45 CEST
This commit is contained in:
parent
a30306e3d5
commit
1eb0d3e173
21 changed files with 392 additions and 87 deletions
|
|
@ -203,10 +203,7 @@ pub enum Change {
|
|||
}
|
||||
|
||||
impl Xwindow {
|
||||
pub fn new(
|
||||
data: &Rc<XwindowData>,
|
||||
surface: &Rc<WlSurface>,
|
||||
) -> Self {
|
||||
pub fn new(data: &Rc<XwindowData>, surface: &Rc<WlSurface>) -> Self {
|
||||
Self {
|
||||
id: data.state.node_ids.next(),
|
||||
seat_state: Default::default(),
|
||||
|
|
@ -323,7 +320,11 @@ impl SurfaceExt for Xwindow {
|
|||
self.surface.unset_ext();
|
||||
self.data.window.set(None);
|
||||
self.data.surface_id.set(None);
|
||||
self.data.state.xwayland.queue.push(XWaylandEvent::SurfaceDestroyed(self.surface.id));
|
||||
self.data
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::SurfaceDestroyed(self.surface.id));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -389,7 +390,11 @@ impl SizedNode for Xwindow {
|
|||
}
|
||||
|
||||
fn close(&self) {
|
||||
self.data.state.xwayland.queue.push(XWaylandEvent::Close(self.data.clone()));
|
||||
self.data
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::Close(self.data.clone()));
|
||||
}
|
||||
|
||||
fn absolute_position(&self) -> Rect {
|
||||
|
|
@ -427,7 +432,11 @@ impl SizedNode for Xwindow {
|
|||
let old = self.data.info.extents.replace(*rect);
|
||||
if old != *rect {
|
||||
if !self.data.info.override_redirect.get() {
|
||||
self.data.state.xwayland.queue.push(XWaylandEvent::Configure(self.clone()));
|
||||
self.data
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::Configure(self.clone()));
|
||||
}
|
||||
if old.position() != rect.position() {
|
||||
self.surface.set_absolute_position(rect.x1(), rect.y1());
|
||||
|
|
@ -482,7 +491,11 @@ impl ToplevelNode for Xwindow {
|
|||
}
|
||||
|
||||
fn activate(&self) {
|
||||
self.data.state.xwayland.queue.push(XWaylandEvent::Activate(self.data.clone()));
|
||||
self.data
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::Activate(self.data.clone()));
|
||||
}
|
||||
|
||||
fn toggle_floating(self: Rc<Self>) {
|
||||
|
|
@ -503,7 +516,11 @@ impl ToplevelNode for Xwindow {
|
|||
}
|
||||
|
||||
fn close(&self) {
|
||||
self.data.state.xwayland.queue.push(XWaylandEvent::Close(self.data.clone()));
|
||||
self.data
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::Close(self.data.clone()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
82
src/ifs/wl_surface/zwp_idle_inhibitor_v1.rs
Normal file
82
src/ifs/wl_surface/zwp_idle_inhibitor_v1.rs
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
ifs::wl_surface::WlSurface,
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{zwp_idle_inhibitor_v1::*, WlSurfaceId, ZwpIdleInhibitorV1Id},
|
||||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
linear_ids!(IdleInhibitorIds, IdleInhibitorId, u64);
|
||||
|
||||
pub struct ZwpIdleInhibitorV1 {
|
||||
pub id: ZwpIdleInhibitorV1Id,
|
||||
pub inhibit_id: IdleInhibitorId,
|
||||
pub client: Rc<Client>,
|
||||
pub surface: Rc<WlSurface>,
|
||||
pub tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
impl ZwpIdleInhibitorV1 {
|
||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpIdleInhibitorV1Error> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
self.client.remove_obj(self)?;
|
||||
if self.surface.idle_inhibitor.take().is_some() {
|
||||
self.deactivate();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn install(self: &Rc<Self>) -> Result<(), ZwpIdleInhibitorV1Error> {
|
||||
if self.surface.idle_inhibitor.get().is_some() {
|
||||
return Err(ZwpIdleInhibitorV1Error::MultipleInhibitors(self.surface.id));
|
||||
}
|
||||
self.surface.idle_inhibitor.set(Some(self.clone()));
|
||||
if self.surface.visible.get() {
|
||||
self.activate();
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn activate(self: &Rc<Self>) {
|
||||
self.client.state.idle.add_inhibitor(self);
|
||||
}
|
||||
|
||||
pub fn deactivate(&self) {
|
||||
self.client.state.idle.remove_inhibitor(self);
|
||||
}
|
||||
}
|
||||
|
||||
object_base2! {
|
||||
ZwpIdleInhibitorV1;
|
||||
|
||||
DESTROY => destroy,
|
||||
}
|
||||
|
||||
impl Object for ZwpIdleInhibitorV1 {
|
||||
fn num_requests(&self) -> u32 {
|
||||
DESTROY + 1
|
||||
}
|
||||
|
||||
fn break_loops(&self) {
|
||||
self.deactivate();
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(ZwpIdleInhibitorV1);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpIdleInhibitorV1Error {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error("The surface {0} already has an inhibitor attached")]
|
||||
MultipleInhibitors(WlSurfaceId),
|
||||
}
|
||||
efrom!(ZwpIdleInhibitorV1Error, ClientError);
|
||||
efrom!(ZwpIdleInhibitorV1Error, MsgParserError);
|
||||
Loading…
Add table
Add a link
Reference in a new issue