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
|
|
@ -3,7 +3,7 @@ use {
|
|||
cli::CliLogLevel,
|
||||
client::{Client, ClientError},
|
||||
globals::{Global, GlobalName},
|
||||
ifs::{jay_log_file::JayLogFile, jay_screenshot::JayScreenshot},
|
||||
ifs::{jay_idle::JayIdle, jay_log_file::JayLogFile, jay_screenshot::JayScreenshot},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
screenshoter::take_screenshot,
|
||||
|
|
@ -17,7 +17,6 @@ use {
|
|||
std::{ops::Deref, rc::Rc},
|
||||
thiserror::Error,
|
||||
};
|
||||
use crate::ifs::jay_idle::JayIdle;
|
||||
|
||||
pub struct JayCompositorGlobal {
|
||||
name: GlobalName,
|
||||
|
|
|
|||
|
|
@ -1,17 +1,14 @@
|
|||
use std::time::Duration;
|
||||
use thiserror::Error;
|
||||
use {
|
||||
crate::{
|
||||
client::Client,
|
||||
client::{Client, ClientError},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
wire::{jay_idle::*},
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{jay_idle::*, JayIdleId},
|
||||
},
|
||||
std::rc::Rc,
|
||||
std::{rc::Rc, time::Duration},
|
||||
thiserror::Error,
|
||||
};
|
||||
use crate::client::ClientError;
|
||||
use crate::utils::buffd::{MsgParser, MsgParserError};
|
||||
use crate::wire::JayIdleId;
|
||||
|
||||
pub struct JayIdle {
|
||||
pub id: JayIdleId,
|
||||
|
|
|
|||
|
|
@ -54,7 +54,11 @@ impl WlCompositor {
|
|||
track!(self.client, surface);
|
||||
self.client.add_client_obj(&surface)?;
|
||||
if self.client.is_xwayland {
|
||||
self.client.state.xwayland.queue.push(XWaylandEvent::SurfaceCreated(surface.clone()));
|
||||
self.client
|
||||
.state
|
||||
.xwayland
|
||||
.queue
|
||||
.push(XWaylandEvent::SurfaceCreated(surface.clone()));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
use {
|
||||
crate::{ifs::wl_seat::WlSeatGlobal, tree::Node, utils::clonecell::CloneCell},
|
||||
crate::{
|
||||
ifs::wl_seat::WlSeatGlobal, tree::Node, utils::clonecell::CloneCell,
|
||||
xwayland::XWaylandEvent,
|
||||
},
|
||||
std::rc::Rc,
|
||||
};
|
||||
use crate::xwayland::XWaylandEvent;
|
||||
|
||||
pub struct KbOwnerHolder {
|
||||
default: Rc<DefaultKbOwner>,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ pub mod wl_subsurface;
|
|||
pub mod xdg_surface;
|
||||
pub mod xwindow;
|
||||
pub mod zwlr_layer_surface_v1;
|
||||
pub mod zwp_idle_inhibitor_v1;
|
||||
|
||||
use {
|
||||
crate::{
|
||||
|
|
@ -46,6 +47,7 @@ use {
|
|||
rc::Rc,
|
||||
},
|
||||
thiserror::Error,
|
||||
zwp_idle_inhibitor_v1::ZwpIdleInhibitorV1,
|
||||
};
|
||||
|
||||
#[allow(dead_code)]
|
||||
|
|
@ -103,6 +105,7 @@ pub struct WlSurface {
|
|||
cursors: SmallMap<SeatId, Rc<CursorSurface>, 1>,
|
||||
pub dnd_icons: SmallMap<SeatId, Rc<WlSeatGlobal>, 1>,
|
||||
pub tracker: Tracker<Self>,
|
||||
idle_inhibitor: CloneCell<Option<Rc<ZwpIdleInhibitorV1>>>,
|
||||
}
|
||||
|
||||
impl Debug for WlSurface {
|
||||
|
|
@ -200,25 +203,26 @@ impl WlSurface {
|
|||
id,
|
||||
node_id: client.state.node_ids.next(),
|
||||
client: client.clone(),
|
||||
visible: Cell::new(false),
|
||||
visible: Default::default(),
|
||||
role: Cell::new(SurfaceRole::None),
|
||||
pending: Default::default(),
|
||||
input_region: Cell::new(None),
|
||||
opaque_region: Cell::new(None),
|
||||
input_region: Default::default(),
|
||||
opaque_region: Default::default(),
|
||||
extents: Default::default(),
|
||||
buffer_abs_pos: Cell::new(Default::default()),
|
||||
need_extents_update: Cell::new(false),
|
||||
buffer: CloneCell::new(None),
|
||||
need_extents_update: Default::default(),
|
||||
buffer: Default::default(),
|
||||
buf_x: Default::default(),
|
||||
buf_y: Default::default(),
|
||||
children: Default::default(),
|
||||
ext: CloneCell::new(client.state.none_surface_ext.clone()),
|
||||
frame_requests: RefCell::new(vec![]),
|
||||
frame_requests: Default::default(),
|
||||
seat_state: Default::default(),
|
||||
toplevel: Default::default(),
|
||||
cursors: Default::default(),
|
||||
dnd_icons: Default::default(),
|
||||
tracker: Default::default(),
|
||||
idle_inhibitor: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -367,7 +371,7 @@ impl WlSurface {
|
|||
self.unset_dnd_icons();
|
||||
self.unset_cursors();
|
||||
self.ext.get().on_surface_destroy()?;
|
||||
self.node_destroy(true);
|
||||
self.destroy_node(true);
|
||||
{
|
||||
let mut children = self.children.borrow_mut();
|
||||
if let Some(children) = &mut *children {
|
||||
|
|
@ -385,6 +389,7 @@ impl WlSurface {
|
|||
self.frame_requests.borrow_mut().clear();
|
||||
self.toplevel.set(None);
|
||||
self.client.remove_obj(self)?;
|
||||
self.idle_inhibitor.take();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -622,6 +627,7 @@ impl Object for WlSurface {
|
|||
mem::take(self.frame_requests.borrow_mut().deref_mut());
|
||||
self.buffer.set(None);
|
||||
self.toplevel.set(None);
|
||||
self.idle_inhibitor.take();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -638,6 +644,9 @@ impl SizedNode for WlSurface {
|
|||
}
|
||||
|
||||
fn destroy_node(&self, _detach: bool) {
|
||||
if let Some(inhibitor) = self.idle_inhibitor.get() {
|
||||
inhibitor.deactivate();
|
||||
}
|
||||
let children = self.children.borrow();
|
||||
if let Some(ch) = children.deref() {
|
||||
for ss in ch.subsurfaces.values() {
|
||||
|
|
@ -682,6 +691,13 @@ impl SizedNode for WlSurface {
|
|||
|
||||
fn set_visible(&self, visible: bool) {
|
||||
self.visible.set(visible);
|
||||
if let Some(inhibitor) = self.idle_inhibitor.get() {
|
||||
if visible {
|
||||
inhibitor.activate();
|
||||
} else {
|
||||
inhibitor.deactivate();
|
||||
}
|
||||
}
|
||||
let children = self.children.borrow_mut();
|
||||
if let Some(children) = children.deref() {
|
||||
for child in children.subsurfaces.values() {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
122
src/ifs/zwp_idle_inhibit_manager_v1.rs
Normal file
122
src/ifs/zwp_idle_inhibit_manager_v1.rs
Normal file
|
|
@ -0,0 +1,122 @@
|
|||
use {
|
||||
crate::{
|
||||
client::{Client, ClientError},
|
||||
globals::{Global, GlobalName},
|
||||
ifs::{
|
||||
wl_surface::zwp_idle_inhibitor_v1::{ZwpIdleInhibitorV1, ZwpIdleInhibitorV1Error},
|
||||
zxdg_decoration_manager_v1::ZxdgDecorationManagerV1Error,
|
||||
},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::buffd::{MsgParser, MsgParserError},
|
||||
wire::{zwp_idle_inhibit_manager_v1::*, ZwpIdleInhibitManagerV1Id},
|
||||
},
|
||||
std::rc::Rc,
|
||||
thiserror::Error,
|
||||
};
|
||||
|
||||
pub struct ZwpIdleInhibitManagerV1Global {
|
||||
name: GlobalName,
|
||||
}
|
||||
|
||||
impl ZwpIdleInhibitManagerV1Global {
|
||||
pub fn new(name: GlobalName) -> Self {
|
||||
Self { name }
|
||||
}
|
||||
|
||||
fn bind_(
|
||||
self: Rc<Self>,
|
||||
id: ZwpIdleInhibitManagerV1Id,
|
||||
client: &Rc<Client>,
|
||||
version: u32,
|
||||
) -> Result<(), ZxdgDecorationManagerV1Error> {
|
||||
let obj = Rc::new(ZwpIdleInhibitManagerV1 {
|
||||
id,
|
||||
client: client.clone(),
|
||||
_version: version,
|
||||
tracker: Default::default(),
|
||||
});
|
||||
track!(client, obj);
|
||||
client.add_client_obj(&obj)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
global_base!(
|
||||
ZwpIdleInhibitManagerV1Global,
|
||||
ZwpIdleInhibitManagerV1,
|
||||
ZwpIdleInhibitManagerV1Error
|
||||
);
|
||||
|
||||
impl Global for ZwpIdleInhibitManagerV1Global {
|
||||
fn singleton(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn version(&self) -> u32 {
|
||||
1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_global!(ZwpIdleInhibitManagerV1Global);
|
||||
|
||||
pub struct ZwpIdleInhibitManagerV1 {
|
||||
pub id: ZwpIdleInhibitManagerV1Id,
|
||||
pub client: Rc<Client>,
|
||||
pub _version: u32,
|
||||
pub tracker: Tracker<Self>,
|
||||
}
|
||||
|
||||
impl ZwpIdleInhibitManagerV1 {
|
||||
pub fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), ZwpIdleInhibitManagerV1Error> {
|
||||
let _req: Destroy = self.client.parse(self, parser)?;
|
||||
self.client.remove_obj(self)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn create_inhibitor(
|
||||
&self,
|
||||
parser: MsgParser<'_, '_>,
|
||||
) -> Result<(), ZwpIdleInhibitManagerV1Error> {
|
||||
let req: CreateInhibitor = self.client.parse(self, parser)?;
|
||||
let surface = self.client.lookup(req.surface)?;
|
||||
let inhibit = Rc::new(ZwpIdleInhibitorV1 {
|
||||
id: req.id,
|
||||
inhibit_id: self.client.state.idle_inhibitor_ids.next(),
|
||||
client: self.client.clone(),
|
||||
surface,
|
||||
tracker: Default::default(),
|
||||
});
|
||||
track!(self.client, inhibit);
|
||||
self.client.add_client_obj(&inhibit)?;
|
||||
inhibit.install()?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
object_base2! {
|
||||
ZwpIdleInhibitManagerV1;
|
||||
|
||||
DESTROY => destroy,
|
||||
CREATE_INHIBITOR => create_inhibitor,
|
||||
}
|
||||
|
||||
impl Object for ZwpIdleInhibitManagerV1 {
|
||||
fn num_requests(&self) -> u32 {
|
||||
CREATE_INHIBITOR + 1
|
||||
}
|
||||
}
|
||||
|
||||
simple_add_obj!(ZwpIdleInhibitManagerV1);
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ZwpIdleInhibitManagerV1Error {
|
||||
#[error("Parsing failed")]
|
||||
MsgParserError(#[source] Box<MsgParserError>),
|
||||
#[error(transparent)]
|
||||
ClientError(Box<ClientError>),
|
||||
#[error(transparent)]
|
||||
ZwpIdleInhibitorV1Error(#[from] ZwpIdleInhibitorV1Error),
|
||||
}
|
||||
efrom!(ZwpIdleInhibitManagerV1Error, ClientError);
|
||||
efrom!(ZwpIdleInhibitManagerV1Error, MsgParserError);
|
||||
Loading…
Add table
Add a link
Reference in a new issue