all: add HashMapExt
This commit is contained in:
parent
4c0e6d9b51
commit
0d7a07ec40
29 changed files with 99 additions and 69 deletions
|
|
@ -35,6 +35,7 @@ use {
|
|||
clonecell::{CloneCell, UnsafeCellCloneSafe},
|
||||
copyhashmap::CopyHashMap,
|
||||
errorfmt::ErrorFmt,
|
||||
hash_map_ext::HashMapExt,
|
||||
numcell::NumCell,
|
||||
oserror::OsError,
|
||||
smallmap::SmallMap,
|
||||
|
|
@ -184,7 +185,7 @@ impl Backend for MetalBackend {
|
|||
dev.cb.take();
|
||||
}
|
||||
}
|
||||
for (_, dev) in self.device_holder.drm_devices.lock().drain() {
|
||||
for dev in self.device_holder.drm_devices.lock().drain_values() {
|
||||
dev.futures.clear();
|
||||
for crtc in dev.dev.crtcs.values() {
|
||||
crtc.connector.take();
|
||||
|
|
@ -196,13 +197,13 @@ impl Backend for MetalBackend {
|
|||
lease.crtcs.clear();
|
||||
lease.planes.clear();
|
||||
};
|
||||
for (_, mut lease) in dev.dev.leases.lock().drain() {
|
||||
for mut lease in dev.dev.leases.lock().drain_values() {
|
||||
clear_lease(&mut lease);
|
||||
}
|
||||
for (_, mut lease) in dev.dev.leases_to_break.lock().drain() {
|
||||
for mut lease in dev.dev.leases_to_break.lock().drain_values() {
|
||||
clear_lease(&mut lease);
|
||||
}
|
||||
for (_, connector) in dev.connectors.lock().drain() {
|
||||
for connector in dev.connectors.lock().drain_values() {
|
||||
{
|
||||
let d = &mut *connector.display.borrow_mut();
|
||||
d.crtcs.clear();
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ use {
|
|||
state::State,
|
||||
tree::OutputNode,
|
||||
utils::{
|
||||
clonecell::CloneCell, copyhashmap::CopyHashMap, errorfmt::ErrorFmt, rc_eq::rc_eq,
|
||||
transform_ext::TransformExt,
|
||||
clonecell::CloneCell, copyhashmap::CopyHashMap, errorfmt::ErrorFmt,
|
||||
hash_map_ext::HashMapExt, rc_eq::rc_eq, transform_ext::TransformExt,
|
||||
},
|
||||
},
|
||||
std::{cell::Cell, ops::Deref, rc::Rc},
|
||||
|
|
@ -99,7 +99,7 @@ impl CursorUserGroup {
|
|||
.set(self.state.dummy_output.get().unwrap());
|
||||
self.state.remove_cursor_size(self.size.get());
|
||||
self.state.cursor_user_groups.remove(&self.id);
|
||||
for (_, user) in self.users.lock().drain() {
|
||||
for user in self.users.lock().drain_values() {
|
||||
user.detach();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ use {
|
|||
object::Version,
|
||||
state::DeviceHandlerData,
|
||||
tree::{Direction, Node, ToplevelNode},
|
||||
utils::{bitflags::BitflagsExt, smallmap::SmallMap},
|
||||
utils::{bitflags::BitflagsExt, hash_map_ext::HashMapExt, smallmap::SmallMap},
|
||||
wire::WlDataOfferId,
|
||||
xkbcommon::{KeyboardState, XkbState, XKB_KEY_DOWN, XKB_KEY_UP},
|
||||
},
|
||||
|
|
@ -237,7 +237,7 @@ impl WlSeatGlobal {
|
|||
| InputEvent::TabletPadStrip { time_usec, .. } => {
|
||||
self.last_input_usec.set(time_usec);
|
||||
if self.idle_notifications.is_not_empty() {
|
||||
for (_, notification) in self.idle_notifications.lock().drain() {
|
||||
for notification in self.idle_notifications.lock().drain_values() {
|
||||
notification.resume.trigger();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,10 @@ use {
|
|||
object::Version,
|
||||
time::now_usec,
|
||||
tree::{FoundNode, Node},
|
||||
utils::{bindings::PerClientBindings, clonecell::CloneCell, copyhashmap::CopyHashMap},
|
||||
utils::{
|
||||
bindings::PerClientBindings, clonecell::CloneCell, copyhashmap::CopyHashMap,
|
||||
hash_map_ext::HashMapExt,
|
||||
},
|
||||
},
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
|
|
@ -293,18 +296,18 @@ impl WlSeatGlobal {
|
|||
|
||||
pub fn tablet_clear(&self) {
|
||||
self.tablet.seats.clear();
|
||||
for (_, tablet) in self.tablet.tablets.lock().drain() {
|
||||
for tablet in self.tablet.tablets.lock().drain_values() {
|
||||
tablet.pads.clear();
|
||||
tablet.bindings.clear();
|
||||
tablet.tools.clear();
|
||||
}
|
||||
for (_, tool) in self.tablet.tools.lock().drain() {
|
||||
for tool in self.tablet.tools.lock().drain_values() {
|
||||
tool.cursor.detach();
|
||||
tool.opt.tool.take();
|
||||
tool.tool_owner.destroy(&tool);
|
||||
tool.bindings.clear();
|
||||
}
|
||||
for (_, pad) in self.tablet.pads.lock().drain() {
|
||||
for pad in self.tablet.pads.lock().drain_values() {
|
||||
pad.pad_owner.destroy(&pad);
|
||||
pad.tablet.take();
|
||||
pad.bindings.clear();
|
||||
|
|
@ -324,14 +327,14 @@ impl WlSeatGlobal {
|
|||
let Some(tablet) = self.tablet.tablets.remove(&id) else {
|
||||
return;
|
||||
};
|
||||
for (_, tool) in tablet.tools.lock().drain() {
|
||||
for tool in tablet.tools.lock().drain_values() {
|
||||
self.tablet_handle_remove_tool(now_usec(), tool.id);
|
||||
}
|
||||
for (_, pad) in tablet.pads.lock().drain() {
|
||||
for pad in tablet.pads.lock().drain_values() {
|
||||
pad.pad_owner.destroy(&pad);
|
||||
pad.tablet.take();
|
||||
}
|
||||
for (_, binding) in tablet.bindings.lock().drain() {
|
||||
for binding in tablet.bindings.lock().drain_values() {
|
||||
binding.send_removed();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use {
|
|||
wl_surface::WlSurface,
|
||||
},
|
||||
time::{now_usec, usec_to_msec},
|
||||
utils::clonecell::CloneCell,
|
||||
utils::{clonecell::CloneCell, hash_map_ext::HashMapExt},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
|
@ -76,7 +76,7 @@ impl WlSeatGlobal {
|
|||
if let Some(tablet) = pad.tablet.take() {
|
||||
tablet.pads.remove(&pad.id);
|
||||
}
|
||||
for (_, binding) in pad.bindings.lock().drain() {
|
||||
for binding in pad.bindings.lock().drain_values() {
|
||||
binding.send_removed();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use {
|
|||
},
|
||||
rect::Rect,
|
||||
time::usec_to_msec,
|
||||
utils::clonecell::CloneCell,
|
||||
utils::{clonecell::CloneCell, hash_map_ext::HashMapExt},
|
||||
},
|
||||
std::{cell::Cell, rc::Rc},
|
||||
};
|
||||
|
|
@ -31,7 +31,7 @@ impl WlSeatGlobal {
|
|||
tool.opt.tool.take();
|
||||
tool.cursor.detach();
|
||||
tool.tool_owner.destroy(&tool);
|
||||
for (_, binding) in tool.bindings.lock().drain() {
|
||||
for binding in tool.bindings.lock().drain_values() {
|
||||
binding.send_removed();
|
||||
}
|
||||
tool.tablet.tools.remove(&id);
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use {
|
|||
utils::{
|
||||
clonecell::CloneCell,
|
||||
copyhashmap::CopyHashMap,
|
||||
hash_map_ext::HashMapExt,
|
||||
linkedlist::{LinkedList, LinkedNode, NodeRef},
|
||||
numcell::NumCell,
|
||||
},
|
||||
|
|
@ -102,7 +103,7 @@ impl CommitTimelines {
|
|||
}
|
||||
|
||||
pub fn clear(&self) {
|
||||
for (_, list) in self.gc.lock().drain() {
|
||||
for list in self.gc.lock().drain_values() {
|
||||
break_loops(&list);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ use {
|
|||
OutputNode, ToplevelData, ToplevelNode, ToplevelNodeBase, ToplevelNodeId,
|
||||
WorkspaceNode,
|
||||
},
|
||||
utils::clonecell::CloneCell,
|
||||
utils::{clonecell::CloneCell, hash_map_ext::HashMapExt},
|
||||
wire::{xdg_toplevel::*, XdgToplevelId},
|
||||
},
|
||||
ahash::{AHashMap, AHashSet},
|
||||
|
|
@ -218,7 +218,7 @@ impl XdgToplevelRequestHandler for XdgToplevel {
|
|||
Some(p) => Some(p.children.borrow_mut()),
|
||||
_ => None,
|
||||
};
|
||||
for (_, child) in children.drain() {
|
||||
for child in children.drain_values() {
|
||||
child.parent.set(parent.clone());
|
||||
if let Some(parent_children) = &mut parent_children {
|
||||
parent_children.insert(child.id, child);
|
||||
|
|
@ -418,7 +418,7 @@ impl XdgToplevel {
|
|||
{
|
||||
let new_parent = self.parent.get();
|
||||
let mut children = self.children.borrow_mut();
|
||||
for (_, child) in children.drain() {
|
||||
for child in children.drain_values() {
|
||||
child.parent.set(new_parent.clone());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use {
|
|||
ifs::{wl_buffer::WlBuffer, zwp_linux_dmabuf_v1::ZwpLinuxDmabufV1},
|
||||
leaks::Tracker,
|
||||
object::Object,
|
||||
utils::errorfmt::ErrorFmt,
|
||||
utils::{errorfmt::ErrorFmt, hash_map_ext::HashMapExt},
|
||||
video::dmabuf::{DmaBuf, DmaBufPlane, PlaneVec, MAX_PLANES},
|
||||
wire::{zwp_linux_buffer_params_v1::*, WlBufferId, ZwpLinuxBufferParamsV1Id},
|
||||
},
|
||||
|
|
@ -90,7 +90,7 @@ impl ZwpLinuxBufferParamsV1 {
|
|||
modifier,
|
||||
planes: PlaneVec::new(),
|
||||
};
|
||||
let mut planes: Vec<_> = self.planes.borrow_mut().drain().map(|v| v.1).collect();
|
||||
let mut planes: Vec<_> = self.planes.borrow_mut().drain_values().collect();
|
||||
planes.sort_by_key(|a| a.plane_idx);
|
||||
for (i, p) in planes.into_iter().enumerate() {
|
||||
if p.plane_idx as usize != i {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ use {
|
|||
bitfield::Bitfield,
|
||||
buffd::{BufFdIn, BufFdOut, MsgFormatter, MsgParser, OutBuffer, OutBufferSwapchain},
|
||||
copyhashmap::CopyHashMap,
|
||||
hash_map_ext::HashMapExt,
|
||||
stack::Stack,
|
||||
vec_ext::VecExt,
|
||||
},
|
||||
|
|
@ -105,7 +106,7 @@ impl TestTransport {
|
|||
pub fn kill(&self) {
|
||||
self.outgoing.take();
|
||||
self.incoming.take();
|
||||
for (_, object) in self.objects.lock().drain() {
|
||||
for object in self.objects.lock().drain_values() {
|
||||
object.on_remove(self);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,7 @@ mod leaks {
|
|||
crate::{
|
||||
client::ClientId,
|
||||
utils::{
|
||||
hash_map_ext::HashMapExt,
|
||||
ptr_ext::{MutPtrExt, PtrExt},
|
||||
windows::WindowsExt,
|
||||
},
|
||||
|
|
@ -157,7 +158,7 @@ mod leaks {
|
|||
if map.is_empty() {
|
||||
log::info!("No leaks");
|
||||
}
|
||||
for (_, mut objs) in map.drain() {
|
||||
for mut objs in map.drain_values() {
|
||||
if objs.len() == 0 {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ use {
|
|||
clonecell::CloneCell,
|
||||
copyhashmap::CopyHashMap,
|
||||
errorfmt::ErrorFmt,
|
||||
hash_map_ext::HashMapExt,
|
||||
numcell::NumCell,
|
||||
oserror::OsError,
|
||||
xrd::xrd,
|
||||
|
|
@ -122,7 +123,7 @@ impl PwCon {
|
|||
}
|
||||
|
||||
pub fn kill(&self) {
|
||||
for (_, obj) in self.objects.lock().drain() {
|
||||
for obj in self.objects.lock().drain_values() {
|
||||
obj.break_loops();
|
||||
}
|
||||
self.io.shutdown();
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use {
|
|||
},
|
||||
utils::{
|
||||
bitflags::BitflagsExt, clonecell::CloneCell, copyhashmap::CopyHashMap,
|
||||
errorfmt::ErrorFmt, oserror::OsError,
|
||||
errorfmt::ErrorFmt, hash_map_ext::HashMapExt, oserror::OsError,
|
||||
},
|
||||
video::drm::Drm,
|
||||
wire::{
|
||||
|
|
@ -191,7 +191,7 @@ impl UsrJayRenderCtxOwner for PortalDisplay {
|
|||
impl UsrConOwner for PortalDisplay {
|
||||
fn killed(&self) {
|
||||
log::info!("Removing display {}", self.id);
|
||||
for (_, sc) in self.screencasts.lock().drain() {
|
||||
for sc in self.screencasts.lock().drain_values() {
|
||||
sc.kill();
|
||||
}
|
||||
self.windows.clear();
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ use {
|
|||
utils::{
|
||||
clonecell::{CloneCell, UnsafeCellCloneSafe},
|
||||
copyhashmap::CopyHashMap,
|
||||
hash_map_ext::HashMapExt,
|
||||
},
|
||||
video::dmabuf::{DmaBuf, PlaneVec},
|
||||
wire::jay_screencast::Ready,
|
||||
|
|
@ -267,7 +268,7 @@ impl ScreencastSession {
|
|||
ScreencastPhase::Terminated => {}
|
||||
ScreencastPhase::Selecting(s) => {
|
||||
s.core.reply.err("Session has been terminated");
|
||||
for (_, gui) in s.guis.lock().drain() {
|
||||
for gui in s.guis.lock().drain_values() {
|
||||
gui.kill(false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use {
|
|||
},
|
||||
},
|
||||
theme::Color,
|
||||
utils::copyhashmap::CopyHashMap,
|
||||
utils::{copyhashmap::CopyHashMap, hash_map_ext::HashMapExt},
|
||||
wl_usr::usr_ifs::{
|
||||
usr_jay_select_toplevel::UsrJaySelectToplevelOwner,
|
||||
usr_jay_select_workspace::UsrJaySelectWorkspaceOwner, usr_jay_toplevel::UsrJayToplevel,
|
||||
|
|
@ -53,7 +53,7 @@ enum ButtonRole {
|
|||
|
||||
impl SelectionGui {
|
||||
pub fn kill(&self, upwards: bool) {
|
||||
for (_, surface) in self.surfaces.lock().drain() {
|
||||
for surface in self.surfaces.lock().drain_values() {
|
||||
surface.overlay.data.kill(false);
|
||||
}
|
||||
if let ScreencastPhase::Selecting(s) = self.screencast_session.phase.get() {
|
||||
|
|
@ -159,7 +159,7 @@ impl ButtonOwner for StaticButton {
|
|||
ScreencastPhase::Selecting(selecting) => selecting,
|
||||
_ => return,
|
||||
};
|
||||
for (_, gui) in selecting.guis.lock().drain() {
|
||||
for gui in selecting.guis.lock().drain_values() {
|
||||
gui.kill(false);
|
||||
}
|
||||
let dpy = &self.surface.output.dpy;
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use {
|
|||
theme::Color,
|
||||
utils::{
|
||||
asyncevent::AsyncEvent, clonecell::CloneCell, copyhashmap::CopyHashMap,
|
||||
errorfmt::ErrorFmt, rc_eq::rc_eq,
|
||||
errorfmt::ErrorFmt, hash_map_ext::HashMapExt, rc_eq::rc_eq,
|
||||
},
|
||||
video::gbm::GBM_BO_USE_RENDERING,
|
||||
wire::{
|
||||
|
|
@ -671,7 +671,7 @@ impl WindowData {
|
|||
owner.kill(upwards);
|
||||
}
|
||||
self.render_task.take();
|
||||
for (_, pb) in self.pending_bufs.lock().drain() {
|
||||
for pb in self.pending_bufs.lock().drain_values() {
|
||||
pb.params.con.remove_obj(pb.params.deref());
|
||||
}
|
||||
for buf in self.bufs.borrow_mut().drain(..) {
|
||||
|
|
@ -689,7 +689,7 @@ impl WindowData {
|
|||
|
||||
pub fn allocate_buffers(self: &Rc<Self>) {
|
||||
{
|
||||
for (_, buf) in self.pending_bufs.lock().drain() {
|
||||
for buf in self.pending_bufs.lock().drain_values() {
|
||||
buf.params.con.remove_obj(buf.params.deref());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ use {
|
|||
async_engine::SpawnedFuture,
|
||||
client::ClientCaps,
|
||||
state::State,
|
||||
utils::{copyhashmap::CopyHashMap, errorfmt::ErrorFmt},
|
||||
utils::{copyhashmap::CopyHashMap, errorfmt::ErrorFmt, hash_map_ext::HashMapExt},
|
||||
},
|
||||
std::{
|
||||
cell::Cell,
|
||||
|
|
@ -36,7 +36,7 @@ struct Acceptor {
|
|||
|
||||
impl SecurityContextAcceptors {
|
||||
pub fn clear(&self) {
|
||||
for (_, acceptor) in self.acceptors.lock().drain() {
|
||||
for acceptor in self.acceptors.lock().drain_values() {
|
||||
acceptor.kill();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
10
src/state.rs
10
src/state.rs
|
|
@ -68,8 +68,8 @@ use {
|
|||
utils::{
|
||||
activation_token::ActivationToken, asyncevent::AsyncEvent, bindings::Bindings,
|
||||
clonecell::CloneCell, copyhashmap::CopyHashMap, errorfmt::ErrorFmt, fdcloser::FdCloser,
|
||||
linkedlist::LinkedList, numcell::NumCell, queue::AsyncQueue, refcounted::RefCounted,
|
||||
run_toplevel::RunToplevel,
|
||||
hash_map_ext::HashMapExt, linkedlist::LinkedList, numcell::NumCell, queue::AsyncQueue,
|
||||
refcounted::RefCounted, run_toplevel::RunToplevel,
|
||||
},
|
||||
video::{
|
||||
dmabuf::DmaBufIds,
|
||||
|
|
@ -743,11 +743,11 @@ impl State {
|
|||
self.xwayland.queue.clear();
|
||||
self.idle.inhibitors.clear();
|
||||
self.idle.change.clear();
|
||||
for (_, drm_dev) in self.drm_devs.lock().drain() {
|
||||
for drm_dev in self.drm_devs.lock().drain_values() {
|
||||
drm_dev.handler.take();
|
||||
drm_dev.connectors.clear();
|
||||
}
|
||||
for (_, connector) in self.connectors.lock().drain() {
|
||||
for connector in self.connectors.lock().drain_values() {
|
||||
connector.handler.take();
|
||||
connector.async_event.clear();
|
||||
}
|
||||
|
|
@ -769,7 +769,7 @@ impl State {
|
|||
self.toplevel_lists.clear();
|
||||
self.security_context_acceptors.clear();
|
||||
self.slow_clients.clear();
|
||||
for (_, h) in self.input_device_handlers.borrow_mut().drain() {
|
||||
for h in self.input_device_handlers.borrow_mut().drain_values() {
|
||||
h.async_event.clear();
|
||||
}
|
||||
self.backend_events.clear();
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use {
|
|||
ifs::wl_output::{OutputId, PersistentOutputState, WlOutputGlobal},
|
||||
state::{ConnectorData, OutputData, State},
|
||||
tree::{move_ws_to_output, OutputNode, OutputRenderData, WsMoveConfig},
|
||||
utils::{asyncevent::AsyncEvent, clonecell::CloneCell},
|
||||
utils::{asyncevent::AsyncEvent, clonecell::CloneCell, hash_map_ext::HashMapExt},
|
||||
},
|
||||
std::{
|
||||
cell::{Cell, RefCell},
|
||||
|
|
@ -244,14 +244,14 @@ impl ConnectorHandler {
|
|||
config.connector_disconnected(self.id);
|
||||
}
|
||||
global.clear();
|
||||
for (_, jo) in on.jay_outputs.lock().drain() {
|
||||
for jo in on.jay_outputs.lock().drain_values() {
|
||||
jo.send_destroyed();
|
||||
}
|
||||
let screencasts: Vec<_> = on.screencasts.lock().values().cloned().collect();
|
||||
for sc in screencasts {
|
||||
sc.do_destroy();
|
||||
}
|
||||
for (_, sc) in on.screencopies.lock().drain() {
|
||||
for sc in on.screencopies.lock().drain_values() {
|
||||
sc.send_failed();
|
||||
}
|
||||
global.destroyed.set(true);
|
||||
|
|
@ -310,7 +310,7 @@ impl ConnectorHandler {
|
|||
}
|
||||
};
|
||||
let withdraw = || {
|
||||
for (_, con) in output_data.lease_connectors.lock().drain() {
|
||||
for con in output_data.lease_connectors.lock().drain_values() {
|
||||
con.send_withdrawn();
|
||||
if !con.device.destroyed.get() {
|
||||
con.device.send_done();
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ use {
|
|||
clonecell::CloneCell,
|
||||
double_click_state::DoubleClickState,
|
||||
errorfmt::ErrorFmt,
|
||||
hash_map_ext::HashMapExt,
|
||||
linkedlist::{LinkedList, LinkedNode, NodeRef},
|
||||
numcell::NumCell,
|
||||
rc_eq::rc_eq,
|
||||
|
|
@ -1613,7 +1614,7 @@ impl ToplevelNodeBase for ContainerNode {
|
|||
fn tl_destroy_impl(&self) {
|
||||
mem::take(self.cursors.borrow_mut().deref_mut());
|
||||
let mut cn = self.child_nodes.borrow_mut();
|
||||
for (_, n) in cn.drain() {
|
||||
for n in cn.drain_values() {
|
||||
n.node.tl_destroy();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@ use {
|
|||
},
|
||||
utils::{
|
||||
clonecell::CloneCell, copyhashmap::CopyHashMap, errorfmt::ErrorFmt,
|
||||
linkedlist::LinkedList, scroller::Scroller, transform_ext::TransformExt,
|
||||
hash_map_ext::HashMapExt, linkedlist::LinkedList, scroller::Scroller,
|
||||
transform_ext::TransformExt,
|
||||
},
|
||||
wire::{JayOutputId, JayScreencastId, ZwlrScreencopyFrameV1Id},
|
||||
},
|
||||
|
|
@ -140,7 +141,7 @@ impl OutputNode {
|
|||
return;
|
||||
}
|
||||
let now = Time::now().unwrap();
|
||||
for (_, capture) in self.screencopies.lock().drain() {
|
||||
for capture in self.screencopies.lock().drain_values() {
|
||||
let wl_buffer = match capture.buffer.take() {
|
||||
Some(b) => b,
|
||||
_ => {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ use {
|
|||
utils::{
|
||||
clonecell::CloneCell,
|
||||
copyhashmap::CopyHashMap,
|
||||
hash_map_ext::HashMapExt,
|
||||
numcell::NumCell,
|
||||
smallmap::SmallMap,
|
||||
threshold_counter::ThresholdCounter,
|
||||
|
|
@ -289,16 +290,16 @@ impl ToplevelData {
|
|||
}
|
||||
|
||||
pub fn destroy_node(&self, node: &dyn Node) {
|
||||
for (_, jay_tl) in self.jay_toplevels.lock().drain() {
|
||||
for jay_tl in self.jay_toplevels.lock().drain_values() {
|
||||
jay_tl.destroy();
|
||||
}
|
||||
for (_, screencast) in self.jay_screencasts.lock().drain() {
|
||||
for screencast in self.jay_screencasts.lock().drain_values() {
|
||||
screencast.do_destroy();
|
||||
}
|
||||
self.identifier.set(toplevel_identifier());
|
||||
{
|
||||
let mut handles = self.handles.lock();
|
||||
for (_, handle) in handles.drain() {
|
||||
for handle in handles.drain_values() {
|
||||
handle.send_closed();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ pub mod double_click_state;
|
|||
pub mod errorfmt;
|
||||
pub mod fdcloser;
|
||||
pub mod gfx_api_ext;
|
||||
pub mod hash_map_ext;
|
||||
pub mod hex;
|
||||
pub mod line_logger;
|
||||
pub mod linkedlist;
|
||||
|
|
|
|||
15
src/utils/hash_map_ext.rs
Normal file
15
src/utils/hash_map_ext.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
use std::collections::HashMap;
|
||||
|
||||
pub trait HashMapExt {
|
||||
type V;
|
||||
|
||||
fn drain_values(&mut self) -> impl Iterator<Item = Self::V>;
|
||||
}
|
||||
|
||||
impl<K, V, S> HashMapExt for HashMap<K, V, S> {
|
||||
type V = V;
|
||||
|
||||
fn drain_values(&mut self) -> impl Iterator<Item = Self::V> {
|
||||
self.drain().map(|(_, v)| v)
|
||||
}
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ use {
|
|||
clonecell::{CloneCell, UnsafeCellCloneSafe},
|
||||
copyhashmap::CopyHashMap,
|
||||
errorfmt::ErrorFmt,
|
||||
hash_map_ext::HashMapExt,
|
||||
linkedlist::{LinkedList, LinkedNode},
|
||||
oserror::OsError,
|
||||
},
|
||||
|
|
@ -230,7 +231,7 @@ impl Drop for SyncObjCtx {
|
|||
fn drop(&mut self) {
|
||||
self.inner.links.clear();
|
||||
let mut map = self.inner.handles.lock();
|
||||
for (_, handle) in map.drain() {
|
||||
for handle in map.drain_values() {
|
||||
destroy(&self.inner.drm, handle);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use {
|
|||
io_uring::IoUring,
|
||||
utils::{
|
||||
asyncevent::AsyncEvent, buf::Buf, clonecell::CloneCell, copyhashmap::CopyHashMap,
|
||||
numcell::NumCell, oserror::OsError, stack::Stack,
|
||||
hash_map_ext::HashMapExt, numcell::NumCell, oserror::OsError, stack::Stack,
|
||||
},
|
||||
video::drm::{
|
||||
sync_obj::{SyncObj, SyncObjCtx, SyncObjPoint},
|
||||
|
|
@ -89,7 +89,7 @@ impl WaitForSyncObj {
|
|||
|
||||
pub fn set_ctx(&self, ctx: Option<Rc<SyncObjCtx>>) {
|
||||
self.inner.ctx.set(ctx);
|
||||
let busy_waiters: Vec<_> = self.inner.busy.lock().drain().map(|(_, w)| w).collect();
|
||||
let busy_waiters: Vec<_> = self.inner.busy.lock().drain_values().collect();
|
||||
for waiter in busy_waiters {
|
||||
let res = self.submit_job(
|
||||
waiter.job.id,
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ use {
|
|||
io_uring::{IoUring, IoUringError},
|
||||
time::{Time, TimeError},
|
||||
utils::{
|
||||
buf::TypedBuf, copyhashmap::CopyHashMap, errorfmt::ErrorFmt, numcell::NumCell,
|
||||
oserror::OsError, stack::Stack,
|
||||
buf::TypedBuf, copyhashmap::CopyHashMap, errorfmt::ErrorFmt, hash_map_ext::HashMapExt,
|
||||
numcell::NumCell, oserror::OsError, stack::Stack,
|
||||
},
|
||||
},
|
||||
std::{
|
||||
|
|
@ -204,7 +204,7 @@ impl WheelData {
|
|||
self.destroyed.set(true);
|
||||
self.dispatcher.set(None);
|
||||
self.cached_futures.take();
|
||||
for (_, dispatcher) in self.dispatchers.lock().drain() {
|
||||
for dispatcher in self.dispatchers.lock().drain_values() {
|
||||
dispatcher.complete(Err(WheelError::Destroyed));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ use {
|
|||
clonecell::CloneCell,
|
||||
copyhashmap::CopyHashMap,
|
||||
errorfmt::ErrorFmt,
|
||||
hash_map_ext::HashMapExt,
|
||||
oserror::OsError,
|
||||
vec_ext::VecExt,
|
||||
},
|
||||
|
|
@ -159,7 +160,7 @@ impl UsrCon {
|
|||
|
||||
pub fn kill(&self) {
|
||||
self.dead.set(true);
|
||||
for (_, obj) in self.objects.lock().drain() {
|
||||
for obj in self.objects.lock().drain_values() {
|
||||
if let Some(obj) = obj {
|
||||
obj.break_loops();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,8 @@ use {
|
|||
tree::{Node, ToplevelNode},
|
||||
utils::{
|
||||
bitflags::BitflagsExt, buf::Buf, cell_ext::CellExt, clonecell::CloneCell,
|
||||
copyhashmap::CopyHashMap, errorfmt::ErrorFmt, linkedlist::LinkedList, numcell::NumCell,
|
||||
oserror::OsError, rc_eq::rc_eq,
|
||||
copyhashmap::CopyHashMap, errorfmt::ErrorFmt, hash_map_ext::HashMapExt,
|
||||
linkedlist::LinkedList, numcell::NumCell, oserror::OsError, rc_eq::rc_eq,
|
||||
},
|
||||
wire::WlSurfaceId,
|
||||
wire_xcon::{
|
||||
|
|
@ -171,7 +171,7 @@ struct SelectionData<T: XIpc> {
|
|||
|
||||
impl<T: XIpc> SelectionData<T> {
|
||||
fn destroy(&self) {
|
||||
for (_, offer) in self.offers.lock().drain() {
|
||||
for offer in self.offers.lock().drain_values() {
|
||||
destroy_data_offer::<T>(&offer.offer);
|
||||
}
|
||||
self.active_offer.take();
|
||||
|
|
@ -179,7 +179,7 @@ impl<T: XIpc> SelectionData<T> {
|
|||
}
|
||||
|
||||
fn destroy_sources(&self) {
|
||||
for (_, source) in self.sources.lock().drain() {
|
||||
for source in self.sources.lock().drain_values() {
|
||||
destroy_data_source::<T>(&source);
|
||||
}
|
||||
}
|
||||
|
|
@ -207,7 +207,7 @@ impl Drop for XwmShared {
|
|||
fn drop(&mut self) {
|
||||
self.data.destroy();
|
||||
self.primary_selection.destroy();
|
||||
for (_, device) in self.devices.lock().drain() {
|
||||
for device in self.devices.lock().drain_values() {
|
||||
destroy_data_device::<XClipboardIpc>(&device);
|
||||
destroy_data_device::<XPrimarySelectionIpc>(&device);
|
||||
device.seat.unset_x_data_device(device.id);
|
||||
|
|
@ -260,7 +260,7 @@ enum Initiator {
|
|||
|
||||
impl Drop for Wm {
|
||||
fn drop(&mut self) {
|
||||
for (_, window) in self.windows.drain() {
|
||||
for window in self.windows.drain_values() {
|
||||
if let Some(window) = window.window.take() {
|
||||
window.break_loops();
|
||||
}
|
||||
|
|
@ -1985,7 +1985,7 @@ impl Wm {
|
|||
}
|
||||
{
|
||||
let mut children = data.children.lock();
|
||||
for (_, child) in children.drain() {
|
||||
for child in children.drain_values() {
|
||||
child.parent.set(None);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue