Merge pull request #113 from mahkoh/jorth/clone-cell-utils
all: add (Clone)Cell::is_some and is_none
This commit is contained in:
commit
3eb5932495
32 changed files with 98 additions and 62 deletions
|
|
@ -408,7 +408,7 @@ impl MetalConnector {
|
||||||
let dd = self.display.borrow_mut();
|
let dd = self.display.borrow_mut();
|
||||||
self.enabled.get()
|
self.enabled.get()
|
||||||
&& dd.connection == ConnectorStatus::Connected
|
&& dd.connection == ConnectorStatus::Connected
|
||||||
&& self.primary_plane.get().is_some()
|
&& self.primary_plane.is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn schedule_present(&self) {
|
pub fn schedule_present(&self) {
|
||||||
|
|
@ -1631,7 +1631,7 @@ impl MetalBackend {
|
||||||
let mut preserve = Preserve::default();
|
let mut preserve = Preserve::default();
|
||||||
self.init_drm_device(dev, &mut preserve)?;
|
self.init_drm_device(dev, &mut preserve)?;
|
||||||
for connector in dev.connectors.lock().values() {
|
for connector in dev.connectors.lock().values() {
|
||||||
if connector.primary_plane.get().is_some() {
|
if connector.primary_plane.is_some() {
|
||||||
connector.schedule_present();
|
connector.schedule_present();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2194,7 +2194,7 @@ impl MetalBackend {
|
||||||
}
|
}
|
||||||
let crtc = 'crtc: {
|
let crtc = 'crtc: {
|
||||||
for crtc in dd.crtcs.values() {
|
for crtc in dd.crtcs.values() {
|
||||||
if crtc.connector.get().is_none() {
|
if crtc.connector.is_none() {
|
||||||
break 'crtc crtc.clone();
|
break 'crtc crtc.clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ impl ExtSessionLockV1 {
|
||||||
self.client.add_client_obj(&new)?;
|
self.client.add_client_obj(&new)?;
|
||||||
if !output.global.destroyed.get() && !self.finished.get() {
|
if !output.global.destroyed.get() && !self.finished.get() {
|
||||||
if let Some(node) = output.global.node.get() {
|
if let Some(node) = output.global.node.get() {
|
||||||
if node.lock_surface.get().is_some() {
|
if node.lock_surface.is_some() {
|
||||||
return Err(ExtSessionLockV1Error::OutputAlreadyLocked);
|
return Err(ExtSessionLockV1Error::OutputAlreadyLocked);
|
||||||
}
|
}
|
||||||
node.lock_surface.set(Some(new.clone()));
|
node.lock_surface.set(Some(new.clone()));
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,8 @@ use {
|
||||||
client::{Client, ClientError, ClientId, WaylandObject},
|
client::{Client, ClientError, ClientId, WaylandObject},
|
||||||
ifs::wl_seat::{WlSeatError, WlSeatGlobal},
|
ifs::wl_seat::{WlSeatError, WlSeatGlobal},
|
||||||
utils::{
|
utils::{
|
||||||
bitflags::BitflagsExt, clonecell::CloneCell, numcell::NumCell, smallmap::SmallMap,
|
bitflags::BitflagsExt, cell_ext::CellExt, clonecell::CloneCell, numcell::NumCell,
|
||||||
|
smallmap::SmallMap,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
ahash::AHashSet,
|
ahash::AHashSet,
|
||||||
|
|
@ -164,11 +165,11 @@ pub fn attach_seat<T: IpcVtable>(
|
||||||
}
|
}
|
||||||
state |= SOURCE_STATE_USED;
|
state |= SOURCE_STATE_USED;
|
||||||
if role == Role::Dnd {
|
if role == Role::Dnd {
|
||||||
if data.actions.get().is_none() {
|
if data.actions.is_none() {
|
||||||
return Err(IpcError::ActionsNotSet);
|
return Err(IpcError::ActionsNotSet);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if data.actions.get().is_some() {
|
if data.actions.is_some() {
|
||||||
return Err(IpcError::ActionsSet);
|
return Err(IpcError::ActionsSet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ use {
|
||||||
utils::{
|
utils::{
|
||||||
bitflags::BitflagsExt,
|
bitflags::BitflagsExt,
|
||||||
buffd::{MsgParser, MsgParserError},
|
buffd::{MsgParser, MsgParserError},
|
||||||
|
cell_ext::CellExt,
|
||||||
},
|
},
|
||||||
wire::{wl_data_source::*, WlDataSourceId},
|
wire::{wl_data_source::*, WlDataSourceId},
|
||||||
xwayland::XWaylandEvent,
|
xwayland::XWaylandEvent,
|
||||||
|
|
@ -186,7 +187,7 @@ impl WlDataSource {
|
||||||
|
|
||||||
fn set_actions(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataSourceError> {
|
fn set_actions(&self, parser: MsgParser<'_, '_>) -> Result<(), WlDataSourceError> {
|
||||||
let req: SetActions = self.data.client.parse(self, parser)?;
|
let req: SetActions = self.data.client.parse(self, parser)?;
|
||||||
if self.data.actions.get().is_some() {
|
if self.data.actions.is_some() {
|
||||||
return Err(WlDataSourceError::AlreadySet);
|
return Err(WlDataSourceError::AlreadySet);
|
||||||
}
|
}
|
||||||
if req.dnd_actions & !DND_ALL != 0 {
|
if req.dnd_actions & !DND_ALL != 0 {
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,7 @@ impl WlBuffer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WlBufferStorage::Dmabuf(img) => {
|
WlBufferStorage::Dmabuf(img) => {
|
||||||
if self.texture.get().is_none() {
|
if self.texture.is_none() {
|
||||||
self.texture.set(Some(img.clone().to_texture()?));
|
self.texture.set(Some(img.clone().to_texture()?));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -226,7 +226,7 @@ impl WlBuffer {
|
||||||
// nothing
|
// nothing
|
||||||
}
|
}
|
||||||
WlBufferStorage::Dmabuf(img) => {
|
WlBufferStorage::Dmabuf(img) => {
|
||||||
if self.famebuffer.get().is_none() {
|
if self.famebuffer.is_none() {
|
||||||
self.famebuffer.set(Some(img.clone().to_framebuffer()?));
|
self.famebuffer.set(Some(img.clone().to_framebuffer()?));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -432,7 +432,7 @@ impl WlSeatGlobal {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn maybe_constrain(&self, surface: &WlSurface, x: Fixed, y: Fixed) {
|
fn maybe_constrain(&self, surface: &WlSurface, x: Fixed, y: Fixed) {
|
||||||
if self.constraint.get().is_some() {
|
if self.constraint.is_some() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let candidate = match surface.constraints.get(&self.id) {
|
let candidate = match surface.constraints.get(&self.id) {
|
||||||
|
|
@ -543,8 +543,7 @@ impl WlSeatGlobal {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_mono(&self) -> Option<bool> {
|
pub fn get_mono(&self) -> Option<bool> {
|
||||||
self.kb_parent_container()
|
self.kb_parent_container().map(|c| c.mono_child.is_some())
|
||||||
.map(|c| c.mono_child.get().is_some())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_split(&self) -> Option<ContainerSplit> {
|
pub fn get_split(&self) -> Option<ContainerSplit> {
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ use {
|
||||||
},
|
},
|
||||||
utils::{
|
utils::{
|
||||||
buffd::{MsgParser, MsgParserError},
|
buffd::{MsgParser, MsgParserError},
|
||||||
|
cell_ext::CellExt,
|
||||||
clonecell::CloneCell,
|
clonecell::CloneCell,
|
||||||
copyhashmap::CopyHashMap,
|
copyhashmap::CopyHashMap,
|
||||||
linkedlist::LinkedList,
|
linkedlist::LinkedList,
|
||||||
|
|
@ -677,7 +678,7 @@ impl WlSurface {
|
||||||
}
|
}
|
||||||
if viewport_changed {
|
if viewport_changed {
|
||||||
if let Some(rect) = self.src_rect.get() {
|
if let Some(rect) = self.src_rect.get() {
|
||||||
if self.dst_size.get().is_none() {
|
if self.dst_size.is_none() {
|
||||||
if !rect[2].is_integer() || !rect[3].is_integer() {
|
if !rect[2].is_integer() || !rect[3].is_integer() {
|
||||||
return Err(WlSurfaceError::NonIntegerViewportSize);
|
return Err(WlSurfaceError::NonIntegerViewportSize);
|
||||||
}
|
}
|
||||||
|
|
@ -773,7 +774,7 @@ impl WlSurface {
|
||||||
new_size = Some((width, height));
|
new_size = Some((width, height));
|
||||||
}
|
}
|
||||||
if transform_changed || Some(buffer.rect) != old_raw_size {
|
if transform_changed || Some(buffer.rect) != old_raw_size {
|
||||||
let (x1, y1, x2, y2) = if self.src_rect.get().is_none() {
|
let (x1, y1, x2, y2) = if self.src_rect.is_none() {
|
||||||
(0.0, 0.0, 1.0, 1.0)
|
(0.0, 0.0, 1.0, 1.0)
|
||||||
} else {
|
} else {
|
||||||
let (width, height) =
|
let (width, height) =
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ impl WpFractionalScaleV1 {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn install(self: &Rc<Self>) -> Result<(), WpFractionalScaleError> {
|
pub fn install(self: &Rc<Self>) -> Result<(), WpFractionalScaleError> {
|
||||||
if self.surface.fractional_scale.get().is_some() {
|
if self.surface.fractional_scale.is_some() {
|
||||||
return Err(WpFractionalScaleError::Exists);
|
return Err(WpFractionalScaleError::Exists);
|
||||||
}
|
}
|
||||||
self.surface.fractional_scale.set(Some(self.clone()));
|
self.surface.fractional_scale.set(Some(self.clone()));
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ pub struct WpTearingControlV1 {
|
||||||
|
|
||||||
impl WpTearingControlV1 {
|
impl WpTearingControlV1 {
|
||||||
pub fn install(self: &Rc<Self>) -> Result<(), WpTearingControlV1Error> {
|
pub fn install(self: &Rc<Self>) -> Result<(), WpTearingControlV1Error> {
|
||||||
if self.surface.tearing_control.get().is_some() {
|
if self.surface.tearing_control.is_some() {
|
||||||
return Err(WpTearingControlV1Error::AlreadyAttached(self.surface.id));
|
return Err(WpTearingControlV1Error::AlreadyAttached(self.surface.id));
|
||||||
}
|
}
|
||||||
self.surface.tearing_control.set(Some(self.clone()));
|
self.surface.tearing_control.set(Some(self.clone()));
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ impl WpViewport {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn install(self: &Rc<Self>) -> Result<(), WpViewportError> {
|
pub fn install(self: &Rc<Self>) -> Result<(), WpViewportError> {
|
||||||
if self.surface.viewporter.get().is_some() {
|
if self.surface.viewporter.is_some() {
|
||||||
return Err(WpViewportError::ViewportExists);
|
return Err(WpViewportError::ViewportExists);
|
||||||
}
|
}
|
||||||
self.surface.viewporter.set(Some(self.clone()));
|
self.surface.viewporter.set(Some(self.clone()));
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ impl SurfaceExt for XSurface {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_surface_destroy(&self) -> Result<(), WlSurfaceError> {
|
fn on_surface_destroy(&self) -> Result<(), WlSurfaceError> {
|
||||||
if self.xwayland_surface.get().is_some() {
|
if self.xwayland_surface.is_some() {
|
||||||
return Err(WlSurfaceError::ReloObjectStillExists);
|
return Err(WlSurfaceError::ReloObjectStillExists);
|
||||||
}
|
}
|
||||||
self.surface.unset_ext();
|
self.surface.unset_ext();
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,10 @@ use {
|
||||||
ifs::wl_surface::{x_surface::XSurface, WlSurfaceError},
|
ifs::wl_surface::{x_surface::XSurface, WlSurfaceError},
|
||||||
leaks::Tracker,
|
leaks::Tracker,
|
||||||
object::Object,
|
object::Object,
|
||||||
utils::buffd::{MsgParser, MsgParserError},
|
utils::{
|
||||||
|
buffd::{MsgParser, MsgParserError},
|
||||||
|
cell_ext::CellExt,
|
||||||
|
},
|
||||||
wire::{xwayland_surface_v1::*, XwaylandSurfaceV1Id},
|
wire::{xwayland_surface_v1::*, XwaylandSurfaceV1Id},
|
||||||
},
|
},
|
||||||
std::rc::Rc,
|
std::rc::Rc,
|
||||||
|
|
@ -21,7 +24,7 @@ pub struct XwaylandSurfaceV1 {
|
||||||
impl XwaylandSurfaceV1 {
|
impl XwaylandSurfaceV1 {
|
||||||
fn set_serial(&self, parser: MsgParser<'_, '_>) -> Result<(), XwaylandSurfaceV1Error> {
|
fn set_serial(&self, parser: MsgParser<'_, '_>) -> Result<(), XwaylandSurfaceV1Error> {
|
||||||
let req: SetSerial = self.client.parse(self, parser)?;
|
let req: SetSerial = self.client.parse(self, parser)?;
|
||||||
if self.x.surface.xwayland_serial.get().is_some() {
|
if self.x.surface.xwayland_serial.is_some() {
|
||||||
return Err(XwaylandSurfaceV1Error::SerialAlreadySet);
|
return Err(XwaylandSurfaceV1Error::SerialAlreadySet);
|
||||||
}
|
}
|
||||||
let serial = req.serial_lo as u64 | ((req.serial_hi as u64) << 32);
|
let serial = req.serial_lo as u64 | ((req.serial_hi as u64) << 32);
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ impl Xwindow {
|
||||||
surface: &Rc<WlSurface>,
|
surface: &Rc<WlSurface>,
|
||||||
) -> Result<Rc<Self>, XWindowError> {
|
) -> Result<Rc<Self>, XWindowError> {
|
||||||
let xsurface = surface.get_xsurface()?;
|
let xsurface = surface.get_xsurface()?;
|
||||||
if xsurface.xwindow.get().is_some() {
|
if xsurface.xwindow.is_some() {
|
||||||
return Err(XWindowError::AlreadyAttached);
|
return Err(XWindowError::AlreadyAttached);
|
||||||
}
|
}
|
||||||
let tld = ToplevelData::new(
|
let tld = ToplevelData::new(
|
||||||
|
|
@ -235,11 +235,11 @@ impl Xwindow {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_mapped(&self) -> bool {
|
pub fn is_mapped(&self) -> bool {
|
||||||
self.toplevel_data.parent.get().is_some() || self.display_link.borrow_mut().is_some()
|
self.toplevel_data.parent.is_some() || self.display_link.borrow_mut().is_some()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn may_be_mapped(&self) -> bool {
|
pub fn may_be_mapped(&self) -> bool {
|
||||||
self.x.surface.buffer.get().is_some() && self.data.info.mapped.get()
|
self.x.surface.buffer.is_some() && self.data.info.mapped.get()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn map_change(&self) -> Change {
|
fn map_change(&self) -> Change {
|
||||||
|
|
|
||||||
|
|
@ -184,7 +184,7 @@ impl XdgSurface {
|
||||||
|
|
||||||
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgSurfaceError> {
|
fn destroy(&self, parser: MsgParser<'_, '_>) -> Result<(), XdgSurfaceError> {
|
||||||
let _req: Destroy = self.surface.client.parse(self, parser)?;
|
let _req: Destroy = self.surface.client.parse(self, parser)?;
|
||||||
if self.ext.get().is_some() {
|
if self.ext.is_some() {
|
||||||
return Err(XdgSurfaceError::RoleNotYetDestroyed(self.id));
|
return Err(XdgSurfaceError::RoleNotYetDestroyed(self.id));
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
@ -202,7 +202,7 @@ impl XdgSurface {
|
||||||
fn get_toplevel(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), XdgSurfaceError> {
|
fn get_toplevel(self: &Rc<Self>, parser: MsgParser<'_, '_>) -> Result<(), XdgSurfaceError> {
|
||||||
let req: GetToplevel = self.surface.client.parse(&**self, parser)?;
|
let req: GetToplevel = self.surface.client.parse(&**self, parser)?;
|
||||||
self.set_role(XdgSurfaceRole::XdgToplevel)?;
|
self.set_role(XdgSurfaceRole::XdgToplevel)?;
|
||||||
if self.ext.get().is_some() {
|
if self.ext.is_some() {
|
||||||
self.surface.client.protocol_error(
|
self.surface.client.protocol_error(
|
||||||
&**self,
|
&**self,
|
||||||
ALREADY_CONSTRUCTED,
|
ALREADY_CONSTRUCTED,
|
||||||
|
|
@ -232,7 +232,7 @@ impl XdgSurface {
|
||||||
parent = Some(self.surface.client.lookup(req.parent)?);
|
parent = Some(self.surface.client.lookup(req.parent)?);
|
||||||
}
|
}
|
||||||
let positioner = self.surface.client.lookup(req.positioner)?;
|
let positioner = self.surface.client.lookup(req.positioner)?;
|
||||||
if self.ext.get().is_some() {
|
if self.ext.is_some() {
|
||||||
self.surface.client.protocol_error(
|
self.surface.client.protocol_error(
|
||||||
&**self,
|
&**self,
|
||||||
ALREADY_CONSTRUCTED,
|
ALREADY_CONSTRUCTED,
|
||||||
|
|
|
||||||
|
|
@ -355,7 +355,7 @@ impl XdgSurfaceExt for XdgPopup {
|
||||||
};
|
};
|
||||||
let surface = &self.xdg.surface;
|
let surface = &self.xdg.surface;
|
||||||
let state = &surface.client.state;
|
let state = &surface.client.state;
|
||||||
if surface.buffer.get().is_some() {
|
if surface.buffer.is_some() {
|
||||||
if wl.is_none() {
|
if wl.is_none() {
|
||||||
self.xdg.set_workspace(&ws);
|
self.xdg.set_workspace(&ws);
|
||||||
*wl = Some(ws.stacked.add_last(self.clone()));
|
*wl = Some(ws.stacked.add_last(self.clone()));
|
||||||
|
|
|
||||||
|
|
@ -557,8 +557,8 @@ impl XdgSurfaceExt for XdgToplevel {
|
||||||
|
|
||||||
fn post_commit(self: Rc<Self>) {
|
fn post_commit(self: Rc<Self>) {
|
||||||
let surface = &self.xdg.surface;
|
let surface = &self.xdg.surface;
|
||||||
if self.toplevel_data.parent.get().is_some() {
|
if self.toplevel_data.parent.is_some() {
|
||||||
if surface.buffer.get().is_none() {
|
if surface.buffer.is_none() {
|
||||||
self.tl_destroy();
|
self.tl_destroy();
|
||||||
{
|
{
|
||||||
let new_parent = self.parent.get();
|
let new_parent = self.parent.get();
|
||||||
|
|
@ -569,7 +569,7 @@ impl XdgSurfaceExt for XdgToplevel {
|
||||||
}
|
}
|
||||||
self.state.tree_changed();
|
self.state.tree_changed();
|
||||||
}
|
}
|
||||||
} else if surface.buffer.get().is_some() {
|
} else if surface.buffer.is_some() {
|
||||||
if let Some(parent) = self.parent.get() {
|
if let Some(parent) = self.parent.get() {
|
||||||
self.map_child(&parent);
|
self.map_child(&parent);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ impl XwaylandShellV1 {
|
||||||
let req: GetXwaylandSurface = self.client.parse(self, parser)?;
|
let req: GetXwaylandSurface = self.client.parse(self, parser)?;
|
||||||
let surface = self.client.lookup(req.surface)?;
|
let surface = self.client.lookup(req.surface)?;
|
||||||
let xsurface = surface.get_xsurface()?;
|
let xsurface = surface.get_xsurface()?;
|
||||||
if xsurface.xwayland_surface.get().is_some() {
|
if xsurface.xwayland_surface.is_some() {
|
||||||
return Err(XwaylandShellV1Error::AlreadyAttached(surface.id));
|
return Err(XwaylandShellV1Error::AlreadyAttached(surface.id));
|
||||||
}
|
}
|
||||||
let xws = Rc::new(XwaylandSurfaceV1 {
|
let xws = Rc::new(XwaylandSurfaceV1 {
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ use {
|
||||||
utils::{
|
utils::{
|
||||||
bitflags::BitflagsExt,
|
bitflags::BitflagsExt,
|
||||||
buffd::{MsgParser, MsgParserError},
|
buffd::{MsgParser, MsgParserError},
|
||||||
|
cell_ext::CellExt,
|
||||||
linkedlist::LinkedNode,
|
linkedlist::LinkedNode,
|
||||||
numcell::NumCell,
|
numcell::NumCell,
|
||||||
},
|
},
|
||||||
|
|
@ -253,7 +254,7 @@ impl ZwlrLayerSurfaceV1 {
|
||||||
}
|
}
|
||||||
self.size.set((width, height));
|
self.size.set((width, height));
|
||||||
}
|
}
|
||||||
if self.acked_serial.get().is_none() {
|
if self.acked_serial.is_none() {
|
||||||
send_configure = true;
|
send_configure = true;
|
||||||
}
|
}
|
||||||
if send_configure {
|
if send_configure {
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use {
|
||||||
test_error::TestError, test_ifs::test_screenshot::TestJayScreenshot,
|
test_error::TestError, test_ifs::test_screenshot::TestJayScreenshot,
|
||||||
test_object::TestObject, test_transport::TestTransport, testrun::ParseFull,
|
test_object::TestObject, test_transport::TestTransport, testrun::ParseFull,
|
||||||
},
|
},
|
||||||
utils::buffd::MsgParser,
|
utils::{buffd::MsgParser, cell_ext::CellExt},
|
||||||
wire::{
|
wire::{
|
||||||
jay_compositor::{self, *},
|
jay_compositor::{self, *},
|
||||||
jay_screenshot::Dmabuf,
|
jay_screenshot::Dmabuf,
|
||||||
|
|
@ -23,7 +23,7 @@ pub struct TestJayCompositor {
|
||||||
|
|
||||||
impl TestJayCompositor {
|
impl TestJayCompositor {
|
||||||
pub async fn get_client_id(&self) -> Result<ClientId, TestError> {
|
pub async fn get_client_id(&self) -> Result<ClientId, TestError> {
|
||||||
if self.client_id.get().is_none() {
|
if self.client_id.is_none() {
|
||||||
self.tran.send(GetClientId { self_id: self.id })?;
|
self.tran.send(GetClientId { self_id: self.id })?;
|
||||||
}
|
}
|
||||||
self.tran.sync().await;
|
self.tran.sync().await;
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ impl<T> Default for TestExpectedEventHolder<T> {
|
||||||
|
|
||||||
impl<T> TestExpectedEventHolder<T> {
|
impl<T> TestExpectedEventHolder<T> {
|
||||||
pub fn expect(self: &Rc<Self>) -> TestResult<TestExpectedEvent<T>> {
|
pub fn expect(self: &Rc<Self>) -> TestResult<TestExpectedEvent<T>> {
|
||||||
if self.data.get().is_some() {
|
if self.data.is_some() {
|
||||||
bail!("There is already an expected event data");
|
bail!("There is already an expected event data");
|
||||||
}
|
}
|
||||||
let data = Rc::new(TestExpectedEventData {
|
let data = Rc::new(TestExpectedEventData {
|
||||||
|
|
|
||||||
|
|
@ -168,7 +168,7 @@ impl UsrJayRenderCtxOwner for PortalDisplay {
|
||||||
self.render_ctx.set(Some(ctx));
|
self.render_ctx.set(Some(ctx));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if self.render_ctx.get().is_none() {
|
if self.render_ctx.is_none() {
|
||||||
let drm = Drm::open_existing(fd);
|
let drm = Drm::open_existing(fd);
|
||||||
let ctx =
|
let ctx =
|
||||||
match create_gfx_context(&self.state.eng, &self.state.ring, &drm, GfxApi::OpenGl) {
|
match create_gfx_context(&self.state.eng, &self.state.ring, &drm, GfxApi::OpenGl) {
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ impl Renderer<'_> {
|
||||||
pub fn render_output(&mut self, output: &OutputNode, x: i32, y: i32) {
|
pub fn render_output(&mut self, output: &OutputNode, x: i32, y: i32) {
|
||||||
if self.state.lock.locked.get() {
|
if self.state.lock.locked.get() {
|
||||||
if let Some(surface) = output.lock_surface.get() {
|
if let Some(surface) = output.lock_surface.get() {
|
||||||
if surface.surface.buffer.get().is_some() {
|
if surface.surface.buffer.is_some() {
|
||||||
self.render_surface(&surface.surface, x, y, None);
|
self.render_surface(&surface.surface, x, y, None);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -331,7 +331,7 @@ impl State {
|
||||||
if let Some(config) = self.config.get() {
|
if let Some(config) = self.config.get() {
|
||||||
config.devices_enumerated()
|
config.devices_enumerated()
|
||||||
}
|
}
|
||||||
if self.render_ctx.get().is_none() {
|
if self.render_ctx.is_none() {
|
||||||
for dev in self.drm_devs.lock().values() {
|
for dev in self.drm_devs.lock().values() {
|
||||||
if let Ok(version) = dev.dev.version() {
|
if let Ok(version) = dev.dev.version() {
|
||||||
if version.name.contains_str("nvidia") {
|
if version.name.contains_str("nvidia") {
|
||||||
|
|
@ -339,11 +339,11 @@ impl State {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
dev.make_render_device();
|
dev.make_render_device();
|
||||||
if self.render_ctx.get().is_some() {
|
if self.render_ctx.is_some() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if self.render_ctx.get().is_none() {
|
if self.render_ctx.is_none() {
|
||||||
if let Some(dev) = self.drm_devs.lock().values().next() {
|
if let Some(dev) = self.drm_devs.lock().values().next() {
|
||||||
dev.make_render_device();
|
dev.make_render_device();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ impl ConnectorHandler {
|
||||||
for ws in ws_to_move {
|
for ws in ws_to_move {
|
||||||
ws.set_output(&on);
|
ws.set_output(&on);
|
||||||
on.workspaces.add_last_existing(&ws);
|
on.workspaces.add_last_existing(&ws);
|
||||||
if ws.visible_on_desired_output.get() && on.workspace.get().is_none() {
|
if ws.visible_on_desired_output.get() && on.workspace.is_none() {
|
||||||
on.show_workspace(&ws);
|
on.show_workspace(&ws);
|
||||||
} else {
|
} else {
|
||||||
ws.set_visible(false);
|
ws.set_visible(false);
|
||||||
|
|
@ -176,7 +176,7 @@ impl ConnectorHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if source.node.workspace.get().is_none() {
|
if source.node.workspace.is_none() {
|
||||||
if let Some(ws) = source.node.workspaces.first() {
|
if let Some(ws) = source.node.workspaces.first() {
|
||||||
source.node.show_workspace(&ws);
|
source.node.show_workspace(&ws);
|
||||||
ws.flush_jay_workspaces();
|
ws.flush_jay_workspaces();
|
||||||
|
|
@ -184,7 +184,7 @@ impl ConnectorHandler {
|
||||||
}
|
}
|
||||||
source.node.schedule_update_render_data();
|
source.node.schedule_update_render_data();
|
||||||
}
|
}
|
||||||
if on.workspace.get().is_none() {
|
if on.workspace.is_none() {
|
||||||
if let Some(ws) = on.workspaces.first() {
|
if let Some(ws) = on.workspaces.first() {
|
||||||
on.show_workspace(&ws);
|
on.show_workspace(&ws);
|
||||||
ws.flush_jay_workspaces();
|
ws.flush_jay_workspaces();
|
||||||
|
|
|
||||||
|
|
@ -317,7 +317,7 @@ impl ContainerNode {
|
||||||
sum_factors += factor;
|
sum_factors += factor;
|
||||||
}
|
}
|
||||||
self.sum_factors.set(sum_factors);
|
self.sum_factors.set(sum_factors);
|
||||||
if self.mono_child.get().is_some() {
|
if self.mono_child.is_some() {
|
||||||
self.activate_child(&new_ref);
|
self.activate_child(&new_ref);
|
||||||
}
|
}
|
||||||
// log::info!("add_child");
|
// log::info!("add_child");
|
||||||
|
|
@ -575,7 +575,7 @@ impl ContainerNode {
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let new_cursor = if self.mono_child.get().is_some() {
|
let new_cursor = if self.mono_child.is_some() {
|
||||||
KnownCursor::Default
|
KnownCursor::Default
|
||||||
} else if self.split.get() == ContainerSplit::Horizontal {
|
} else if self.split.get() == ContainerSplit::Horizontal {
|
||||||
if y < title_height + 1 {
|
if y < title_height + 1 {
|
||||||
|
|
@ -606,7 +606,7 @@ impl ContainerNode {
|
||||||
fn update_title(&self) {
|
fn update_title(&self) {
|
||||||
let mut title = self.toplevel_data.title.borrow_mut();
|
let mut title = self.toplevel_data.title.borrow_mut();
|
||||||
title.clear();
|
title.clear();
|
||||||
let split = match (self.mono_child.get().is_some(), self.split.get()) {
|
let split = match (self.mono_child.is_some(), self.split.get()) {
|
||||||
(true, _) => "T",
|
(true, _) => "T",
|
||||||
(_, ContainerSplit::Horizontal) => "H",
|
(_, ContainerSplit::Horizontal) => "H",
|
||||||
(_, ContainerSplit::Vertical) => "V",
|
(_, ContainerSplit::Vertical) => "V",
|
||||||
|
|
@ -651,7 +651,7 @@ impl ContainerNode {
|
||||||
rd.underline_rects.clear();
|
rd.underline_rects.clear();
|
||||||
rd.last_active_rect.take();
|
rd.last_active_rect.take();
|
||||||
let last_active = self.focus_history.last().map(|v| v.node.node_id());
|
let last_active = self.focus_history.last().map(|v| v.node.node_id());
|
||||||
let mono = self.mono_child.get().is_some();
|
let mono = self.mono_child.is_some();
|
||||||
let split = self.split.get();
|
let split = self.split.get();
|
||||||
let have_active = self.children.iter().any(|c| c.active.get());
|
let have_active = self.children.iter().any(|c| c.active.get());
|
||||||
let scales = self.state.scales.lock();
|
let scales = self.state.scales.lock();
|
||||||
|
|
@ -762,7 +762,7 @@ impl ContainerNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_mono(self: &Rc<Self>, child: Option<&dyn ToplevelNode>) {
|
pub fn set_mono(self: &Rc<Self>, child: Option<&dyn ToplevelNode>) {
|
||||||
if self.mono_child.get().is_some() == child.is_some() {
|
if self.mono_child.is_some() == child.is_some() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let child = {
|
let child = {
|
||||||
|
|
@ -892,7 +892,7 @@ impl ContainerNode {
|
||||||
let (split, prev) = direction_to_split(direction);
|
let (split, prev) = direction_to_split(direction);
|
||||||
// CASE 2: We're moving the child within the container.
|
// CASE 2: We're moving the child within the container.
|
||||||
if split == self.split.get()
|
if split == self.split.get()
|
||||||
|| (split == ContainerSplit::Horizontal && self.mono_child.get().is_some())
|
|| (split == ContainerSplit::Horizontal && self.mono_child.is_some())
|
||||||
{
|
{
|
||||||
let cc = match self.child_nodes.borrow().get(&child.node_id()) {
|
let cc = match self.child_nodes.borrow().get(&child.node_id()) {
|
||||||
Some(l) => l.to_ref(),
|
Some(l) => l.to_ref(),
|
||||||
|
|
@ -1194,7 +1194,7 @@ impl Node for ContainerNode {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let (kind, child) = 'res: {
|
let (kind, child) = 'res: {
|
||||||
let mono = self.mono_child.get().is_some();
|
let mono = self.mono_child.is_some();
|
||||||
for child in self.children.iter() {
|
for child in self.children.iter() {
|
||||||
let rect = child.title_rect.get();
|
let rect = child.title_rect.get();
|
||||||
if rect.contains(seat_data.x, seat_data.y) {
|
if rect.contains(seat_data.x, seat_data.y) {
|
||||||
|
|
|
||||||
|
|
@ -350,7 +350,7 @@ impl OutputNode {
|
||||||
ws.output_link
|
ws.output_link
|
||||||
.set(Some(self.workspaces.add_last(ws.clone())));
|
.set(Some(self.workspaces.add_last(ws.clone())));
|
||||||
self.state.workspaces.set(name.to_string(), ws.clone());
|
self.state.workspaces.set(name.to_string(), ws.clone());
|
||||||
if self.workspace.get().is_none() {
|
if self.workspace.is_none() {
|
||||||
self.show_workspace(&ws);
|
self.show_workspace(&ws);
|
||||||
}
|
}
|
||||||
let mut clients_to_kill = AHashMap::new();
|
let mut clients_to_kill = AHashMap::new();
|
||||||
|
|
@ -503,7 +503,7 @@ impl OutputNode {
|
||||||
pub fn has_fullscreen(&self) -> bool {
|
pub fn has_fullscreen(&self) -> bool {
|
||||||
self.workspace
|
self.workspace
|
||||||
.get()
|
.get()
|
||||||
.map(|w| w.fullscreen.get().is_some())
|
.map(|w| w.fullscreen.is_some())
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -344,7 +344,7 @@ impl ToplevelData {
|
||||||
node: Rc<dyn ToplevelNode>,
|
node: Rc<dyn ToplevelNode>,
|
||||||
ws: &Rc<WorkspaceNode>,
|
ws: &Rc<WorkspaceNode>,
|
||||||
) {
|
) {
|
||||||
if ws.fullscreen.get().is_some() {
|
if ws.fullscreen.is_some() {
|
||||||
log::info!("Cannot fullscreen a node on a workspace that already has a fullscreen node attached");
|
log::info!("Cannot fullscreen a node on a workspace that already has a fullscreen node attached");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -88,11 +88,11 @@ impl WorkspaceNode {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
self.stacked.is_empty() && self.fullscreen.get().is_none() && self.container.get().is_none()
|
self.stacked.is_empty() && self.fullscreen.is_none() && self.container.is_none()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn stacked_visible(&self) -> bool {
|
pub fn stacked_visible(&self) -> bool {
|
||||||
self.visible.get() && self.fullscreen.get().is_none()
|
self.visible.get() && self.fullscreen.is_none()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn change_extents(&self, rect: &Rect) {
|
pub fn change_extents(&self, rect: &Rect) {
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ pub mod bitflags;
|
||||||
pub mod buf;
|
pub mod buf;
|
||||||
pub mod buffd;
|
pub mod buffd;
|
||||||
pub mod bufio;
|
pub mod bufio;
|
||||||
|
pub mod cell_ext;
|
||||||
pub mod clonecell;
|
pub mod clonecell;
|
||||||
pub mod copyhashmap;
|
pub mod copyhashmap;
|
||||||
pub mod debug_fn;
|
pub mod debug_fn;
|
||||||
|
|
|
||||||
16
src/utils/cell_ext.rs
Normal file
16
src/utils/cell_ext.rs
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
use std::cell::Cell;
|
||||||
|
|
||||||
|
pub trait CellExt {
|
||||||
|
fn is_some(&self) -> bool;
|
||||||
|
fn is_none(&self) -> bool;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: Copy> CellExt for Cell<Option<T>> {
|
||||||
|
fn is_some(&self) -> bool {
|
||||||
|
self.get().is_some()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn is_none(&self) -> bool {
|
||||||
|
self.get().is_none()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -59,6 +59,19 @@ impl<T> CloneCell<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> CloneCell<Option<T>> {
|
||||||
|
#[inline(always)]
|
||||||
|
pub fn is_some(&self) -> bool {
|
||||||
|
unsafe { self.data.get().deref().is_some() }
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn is_none(&self) -> bool {
|
||||||
|
unsafe { self.data.get().deref().is_none() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: Default> Default for CloneCell<T> {
|
impl<T: Default> Default for CloneCell<T> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::new(Default::default())
|
Self::new(Default::default())
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,9 @@ use {
|
||||||
time::Time,
|
time::Time,
|
||||||
tree::{Node, ToplevelNode},
|
tree::{Node, ToplevelNode},
|
||||||
utils::{
|
utils::{
|
||||||
bitflags::BitflagsExt, buf::Buf, clonecell::CloneCell, copyhashmap::CopyHashMap,
|
bitflags::BitflagsExt, buf::Buf, cell_ext::CellExt, clonecell::CloneCell,
|
||||||
errorfmt::ErrorFmt, linkedlist::LinkedList, numcell::NumCell, oserror::OsError,
|
copyhashmap::CopyHashMap, errorfmt::ErrorFmt, linkedlist::LinkedList, numcell::NumCell,
|
||||||
rc_eq::rc_eq,
|
oserror::OsError, rc_eq::rc_eq,
|
||||||
},
|
},
|
||||||
wire::{WlDataDeviceId, WlSurfaceId, ZwpPrimarySelectionDeviceV1Id},
|
wire::{WlDataDeviceId, WlSurfaceId, ZwpPrimarySelectionDeviceV1Id},
|
||||||
wire_xcon::{
|
wire_xcon::{
|
||||||
|
|
@ -1380,7 +1380,7 @@ impl Wm {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create_window(&mut self, data: &Rc<XwindowData>, surface: Rc<WlSurface>) {
|
async fn create_window(&mut self, data: &Rc<XwindowData>, surface: Rc<WlSurface>) {
|
||||||
if data.window.get().is_some() {
|
if data.window.is_some() {
|
||||||
log::error!("The xwindow has already been constructed");
|
log::error!("The xwindow has already been constructed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -2283,7 +2283,7 @@ impl Wm {
|
||||||
Some(w) => w,
|
Some(w) => w,
|
||||||
_ => return Ok(()),
|
_ => return Ok(()),
|
||||||
};
|
};
|
||||||
if data.info.pid.get().is_none() || data.info.pid.get() != fw.info.pid.get() {
|
if data.info.pid.is_none() || data.info.pid.get() != fw.info.pid.get() {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
let win = match data.window.get() {
|
let win = match data.window.get() {
|
||||||
|
|
@ -2398,7 +2398,7 @@ impl Wm {
|
||||||
Some(d) => d.clone(),
|
Some(d) => d.clone(),
|
||||||
_ => return Ok(()),
|
_ => return Ok(()),
|
||||||
};
|
};
|
||||||
if data.surface_id.get().is_some() {
|
if data.surface_id.is_some() {
|
||||||
log::error!("Surface id is already set");
|
log::error!("Surface id is already set");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue