diff --git a/Cargo.lock b/Cargo.lock index d195fa0e..c7af9f99 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -499,7 +499,6 @@ dependencies = [ "ash", "backtrace", "bincode", - "bitflags 2.4.2", "bstr", "byteorder", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 56098442..3e9b10b7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,6 @@ log = { version = "0.4.20", features = ["std"] } futures-util = "0.3.30" num-traits = "0.2.17" num-derive = "0.4.1" -bitflags = "2.4.2" libloading = "0.8.1" bstr = { version = "1.9.0", default-features = false, features = ["std"] } isnt = "0.1.0" diff --git a/src/gfx_apis/gl/egl.rs b/src/gfx_apis/gl/egl.rs index a24affc5..1eb65803 100644 --- a/src/gfx_apis/gl/egl.rs +++ b/src/gfx_apis/gl/egl.rs @@ -5,7 +5,7 @@ use { EGL_DEBUG_MSG_ERROR_KHR, EGL_DEBUG_MSG_INFO_KHR, EGL_DEBUG_MSG_WARN_KHR, EGL_NONE, EGL_OPENGL_ES_API, EGL_TRUE, }, - ext::{get_client_ext, ClientExt}, + ext::{get_client_ext, ClientExt, EXT_PLATFORM_BASE, KHR_DEBUG, KHR_PLATFORM_GBM}, proc::ExtProc, RenderError, }, @@ -32,13 +32,13 @@ pub(crate) static PROCS: Lazy = Lazy::new(ExtProc::load); pub(crate) static EXTS: Lazy = Lazy::new(get_client_ext); pub(in crate::gfx_apis::gl) fn init() -> Result<(), RenderError> { - if !EXTS.contains(ClientExt::EXT_PLATFORM_BASE) { + if !EXTS.contains(EXT_PLATFORM_BASE) { return Err(RenderError::ExtPlatformBase); } - if !EXTS.contains(ClientExt::KHR_PLATFORM_GBM) { + if !EXTS.contains(KHR_PLATFORM_GBM) { return Err(RenderError::GbmExt); } - if EXTS.contains(ClientExt::KHR_DEBUG) { + if EXTS.contains(KHR_DEBUG) { let attrib: &[EGLAttrib] = &[ EGL_DEBUG_MSG_CRITICAL_KHR as _, EGL_TRUE as _, diff --git a/src/gfx_apis/gl/egl/context.rs b/src/gfx_apis/gl/egl/context.rs index 8a90ef91..a7ca813b 100644 --- a/src/gfx_apis/gl/egl/context.rs +++ b/src/gfx_apis/gl/egl/context.rs @@ -9,7 +9,7 @@ use { }, PROCS, }, - ext::{DisplayExt, GlExt}, + ext::{GlExt, EXT_CREATE_CONTEXT_ROBUSTNESS}, sys::{ GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB, GL_UNKNOWN_CONTEXT_RESET_ARB, @@ -44,11 +44,7 @@ static mut CURRENT: EGLContext = EGLContext::none(); impl EglContext { pub fn reset_status(&self) -> Option { - if !self - .dpy - .exts - .contains(DisplayExt::EXT_CREATE_CONTEXT_ROBUSTNESS) - { + if !self.dpy.exts.contains(EXT_CREATE_CONTEXT_ROBUSTNESS) { return None; } let status = self.with_current(|| unsafe { diff --git a/src/gfx_apis/gl/egl/display.rs b/src/gfx_apis/gl/egl/display.rs index d6e7e6ba..0091893f 100644 --- a/src/gfx_apis/gl/egl/display.rs +++ b/src/gfx_apis/gl/egl/display.rs @@ -23,7 +23,12 @@ use { }, PROCS, }, - ext::{get_display_ext, get_gl_ext, DisplayExt, GlExt}, + ext::{ + get_display_ext, get_gl_ext, DisplayExt, GlExt, EXT_CREATE_CONTEXT_ROBUSTNESS, + EXT_IMAGE_DMA_BUF_IMPORT_MODIFIERS, GL_OES_EGL_IMAGE, GL_OES_EGL_IMAGE_EXTERNAL, + KHR_IMAGE_BASE, KHR_NO_CONFIG_CONTEXT, KHR_SURFACELESS_CONTEXT, + MESA_CONFIGLESS_CONTEXT, + }, sys::{ eglInitialize, EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT, EGL_LOSE_CONTEXT_ON_RESET_EXT, EGL_PLATFORM_GBM_KHR, @@ -74,7 +79,7 @@ impl EglDisplay { return Err(RenderError::GetDisplay); } let mut dpy = EglDisplay { - exts: DisplayExt::empty(), + exts: DisplayExt::none(), formats: AHashMap::new(), gbm: Rc::new(gbm), dpy, @@ -85,22 +90,19 @@ impl EglDisplay { return Err(RenderError::Initialize); } dpy.exts = get_display_ext(dpy.dpy); - if !dpy.exts.intersects(DisplayExt::KHR_IMAGE_BASE) { + if !dpy.exts.intersects(KHR_IMAGE_BASE) { return Err(RenderError::ImageBase); } - if !dpy - .exts - .intersects(DisplayExt::EXT_IMAGE_DMA_BUF_IMPORT_MODIFIERS) - { + if !dpy.exts.intersects(EXT_IMAGE_DMA_BUF_IMPORT_MODIFIERS) { return Err(RenderError::DmaBufImport); } if !dpy .exts - .intersects(DisplayExt::KHR_NO_CONFIG_CONTEXT | DisplayExt::MESA_CONFIGLESS_CONTEXT) + .intersects(KHR_NO_CONFIG_CONTEXT | MESA_CONFIGLESS_CONTEXT) { return Err(RenderError::ConfiglessContext); } - if !dpy.exts.intersects(DisplayExt::KHR_SURFACELESS_CONTEXT) { + if !dpy.exts.intersects(KHR_SURFACELESS_CONTEXT) { return Err(RenderError::SurfacelessContext); } dpy.formats = query_formats(dpy.dpy)?; @@ -113,10 +115,7 @@ impl EglDisplay { self: &Rc, ) -> Result, RenderError> { let mut attrib = vec![EGL_CONTEXT_CLIENT_VERSION, 2]; - if self - .exts - .contains(DisplayExt::EXT_CREATE_CONTEXT_ROBUSTNESS) - { + if self.exts.contains(EXT_CREATE_CONTEXT_ROBUSTNESS) { attrib.push(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT); attrib.push(EGL_LOSE_CONTEXT_ON_RESET_EXT); } else { @@ -136,17 +135,17 @@ impl EglDisplay { } let mut ctx = EglContext { dpy: self.clone(), - ext: GlExt::empty(), + ext: GlExt::none(), ctx, formats: Default::default(), }; ctx.ext = ctx.with_current(|| Ok(get_gl_ext()))?; - if !ctx.ext.contains(GlExt::GL_OES_EGL_IMAGE) { + if !ctx.ext.contains(GL_OES_EGL_IMAGE) { return Err(RenderError::OesEglImage); } ctx.formats = { let mut formats = AHashMap::new(); - let supports_external_only = ctx.ext.contains(GlExt::GL_OES_EGL_IMAGE_EXTERNAL); + let supports_external_only = ctx.ext.contains(GL_OES_EGL_IMAGE_EXTERNAL); for (&drm, format) in &self.formats { if format.implicit_external_only && !supports_external_only { continue; diff --git a/src/gfx_apis/gl/ext.rs b/src/gfx_apis/gl/ext.rs index 02fac8cd..500aaf40 100644 --- a/src/gfx_apis/gl/ext.rs +++ b/src/gfx_apis/gl/ext.rs @@ -46,95 +46,74 @@ where base } -bitflags::bitflags! { - #[derive(Copy, Clone, Debug)] - pub struct ClientExt: u32 { - const EXT_CLIENT_EXTENSION = 1 << 0; - const EXT_PLATFORM_BASE = 1 << 1; - const KHR_PLATFORM_GBM = 1 << 2; - const KHR_DEBUG = 1 << 3; - } +bitflags! { + ClientExt: u32; + EXT_CLIENT_EXTENSION = 1 << 0, + EXT_PLATFORM_BASE = 1 << 1, + KHR_PLATFORM_GBM = 1 << 2, + KHR_DEBUG = 1 << 3, } pub fn get_client_ext() -> ClientExt { let map = [ - ("EGL_EXT_platform_base", ClientExt::EXT_PLATFORM_BASE), - ("EGL_KHR_platform_gbm", ClientExt::KHR_PLATFORM_GBM), - ("EGL_KHR_debug", ClientExt::KHR_DEBUG), + ("EGL_EXT_platform_base", EXT_PLATFORM_BASE), + ("EGL_KHR_platform_gbm", KHR_PLATFORM_GBM), + ("EGL_KHR_debug", KHR_DEBUG), ]; match unsafe { get_dpy_extensions(EGLDisplay::none()) } { - Some(exts) => get_typed_ext(&exts, ClientExt::EXT_CLIENT_EXTENSION, &map), - _ => ClientExt::empty(), + Some(exts) => get_typed_ext(&exts, EXT_CLIENT_EXTENSION, &map), + _ => ClientExt::none(), } } -bitflags::bitflags! { - #[derive(Copy, Clone, Debug)] - pub struct DisplayExt: u32 { - const KHR_IMAGE_BASE = 1 << 0; - const EXT_IMAGE_DMA_BUF_IMPORT = 1 << 1; - const EXT_IMAGE_DMA_BUF_IMPORT_MODIFIERS = 1 << 2; - const KHR_NO_CONFIG_CONTEXT = 1 << 3; - const MESA_CONFIGLESS_CONTEXT = 1 << 4; - const KHR_SURFACELESS_CONTEXT = 1 << 5; - const IMG_CONTEXT_PRIORITY = 1 << 6; - const EXT_CREATE_CONTEXT_ROBUSTNESS = 1 << 7; - } +bitflags! { + DisplayExt: u32; + KHR_IMAGE_BASE = 1 << 0, + EXT_IMAGE_DMA_BUF_IMPORT = 1 << 1, + EXT_IMAGE_DMA_BUF_IMPORT_MODIFIERS = 1 << 2, + KHR_NO_CONFIG_CONTEXT = 1 << 3, + MESA_CONFIGLESS_CONTEXT = 1 << 4, + KHR_SURFACELESS_CONTEXT = 1 << 5, + IMG_CONTEXT_PRIORITY = 1 << 6, + EXT_CREATE_CONTEXT_ROBUSTNESS = 1 << 7, } pub(crate) unsafe fn get_display_ext(dpy: EGLDisplay) -> DisplayExt { let map = [ - ("EGL_KHR_image_base", DisplayExt::KHR_IMAGE_BASE), - ( - "EGL_EXT_image_dma_buf_import", - DisplayExt::EXT_IMAGE_DMA_BUF_IMPORT, - ), + ("EGL_KHR_image_base", KHR_IMAGE_BASE), + ("EGL_EXT_image_dma_buf_import", EXT_IMAGE_DMA_BUF_IMPORT), ( "EGL_EXT_image_dma_buf_import_modifiers", - DisplayExt::EXT_IMAGE_DMA_BUF_IMPORT_MODIFIERS, + EXT_IMAGE_DMA_BUF_IMPORT_MODIFIERS, ), - ( - "EGL_KHR_no_config_context", - DisplayExt::KHR_NO_CONFIG_CONTEXT, - ), - ( - "EGL_MESA_configless_context", - DisplayExt::MESA_CONFIGLESS_CONTEXT, - ), - ( - "EGL_KHR_surfaceless_context", - DisplayExt::KHR_SURFACELESS_CONTEXT, - ), - ("EGL_IMG_context_priority", DisplayExt::IMG_CONTEXT_PRIORITY), + ("EGL_KHR_no_config_context", KHR_NO_CONFIG_CONTEXT), + ("EGL_MESA_configless_context", MESA_CONFIGLESS_CONTEXT), + ("EGL_KHR_surfaceless_context", KHR_SURFACELESS_CONTEXT), + ("EGL_IMG_context_priority", IMG_CONTEXT_PRIORITY), ( "EGL_EXT_create_context_robustness", - DisplayExt::EXT_CREATE_CONTEXT_ROBUSTNESS, + EXT_CREATE_CONTEXT_ROBUSTNESS, ), ]; match get_dpy_extensions(dpy) { - Some(exts) => get_typed_ext(&exts, DisplayExt::empty(), &map), - _ => DisplayExt::empty(), + Some(exts) => get_typed_ext(&exts, DisplayExt::none(), &map), + _ => DisplayExt::none(), } } -bitflags::bitflags! { - #[derive(Copy, Clone, Debug)] - pub struct GlExt: u32 { - const GL_OES_EGL_IMAGE = 1 << 0; - const GL_OES_EGL_IMAGE_EXTERNAL = 1 << 1; - } +bitflags! { + GlExt: u32; + GL_OES_EGL_IMAGE = 1 << 0, + GL_OES_EGL_IMAGE_EXTERNAL = 1 << 1, } pub fn get_gl_ext() -> GlExt { let map = [ - ("GL_OES_EGL_image", GlExt::GL_OES_EGL_IMAGE), - ( - "GL_OES_EGL_image_external", - GlExt::GL_OES_EGL_IMAGE_EXTERNAL, - ), + ("GL_OES_EGL_image", GL_OES_EGL_IMAGE), + ("GL_OES_EGL_image_external", GL_OES_EGL_IMAGE_EXTERNAL), ]; match unsafe { get_extensions(glGetString(GL_EXTENSIONS) as _) } { - Some(exts) => get_typed_ext(&exts, GlExt::empty(), &map), - _ => GlExt::empty(), + Some(exts) => get_typed_ext(&exts, GlExt::none(), &map), + _ => GlExt::none(), } } diff --git a/src/gfx_apis/gl/gl/texture.rs b/src/gfx_apis/gl/gl/texture.rs index f083eaa6..cded2e9f 100644 --- a/src/gfx_apis/gl/gl/texture.rs +++ b/src/gfx_apis/gl/gl/texture.rs @@ -3,7 +3,7 @@ use { format::Format, gfx_apis::gl::{ egl::{context::EglContext, image::EglImage, PROCS}, - ext::GlExt, + ext::GL_OES_EGL_IMAGE_EXTERNAL, gl::sys::{ glBindTexture, glDeleteTextures, glGenTextures, glPixelStorei, glTexImage2D, glTexParameteri, GLint, GLuint, GL_CLAMP_TO_EDGE, GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, @@ -38,7 +38,7 @@ impl GlTexture { ctx: &Rc, img: &Rc, ) -> Result { - if !ctx.ext.contains(GlExt::GL_OES_EGL_IMAGE_EXTERNAL) { + if !ctx.ext.contains(GL_OES_EGL_IMAGE_EXTERNAL) { return Err(RenderError::ExternalUnsupported); } let target = image_target(img.external_only); diff --git a/src/gfx_apis/gl/renderer/context.rs b/src/gfx_apis/gl/renderer/context.rs index b9680151..fc6adad6 100644 --- a/src/gfx_apis/gl/renderer/context.rs +++ b/src/gfx_apis/gl/renderer/context.rs @@ -7,7 +7,7 @@ use { }, gfx_apis::gl::{ egl::{context::EglContext, display::EglDisplay}, - ext::GlExt, + ext::GL_OES_EGL_IMAGE_EXTERNAL, gl::{ program::GlProgram, render_buffer::GlRenderBuffer, sys::GLint, texture::GlTexture, }, @@ -100,7 +100,7 @@ impl GlRenderContext { tex_vert, include_str!("../shaders/tex-alpha.frag.glsl"), )?; - let tex_external = if ctx.ext.contains(GlExt::GL_OES_EGL_IMAGE_EXTERNAL) { + let tex_external = if ctx.ext.contains(GL_OES_EGL_IMAGE_EXTERNAL) { let solid = GlProgram::from_shaders( ctx, tex_vert, diff --git a/src/ifs/wl_surface/xdg_surface/xdg_popup.rs b/src/ifs/wl_surface/xdg_surface/xdg_popup.rs index 39f8ce4b..46b56602 100644 --- a/src/ifs/wl_surface/xdg_surface/xdg_popup.rs +++ b/src/ifs/wl_surface/xdg_surface/xdg_popup.rs @@ -6,7 +6,10 @@ use { ifs::{ wl_seat::{NodeSeatState, WlSeatGlobal}, wl_surface::xdg_surface::{XdgSurface, XdgSurfaceError, XdgSurfaceExt}, - xdg_positioner::{XdgPositioned, XdgPositioner, CA}, + xdg_positioner::{ + XdgPositioned, XdgPositioner, CA_FLIP_X, CA_FLIP_Y, CA_RESIZE_X, CA_RESIZE_Y, + CA_SLIDE_X, CA_SLIDE_Y, + }, }, leaks::Tracker, object::Object, @@ -114,8 +117,8 @@ impl XdgPopup { let output_pos = ws.output.get().global.pos.get(); let mut overflow = output_pos.get_overflow(&abs_pos); if !overflow.is_contained() { - let mut flip_x = positioner.ca.contains(CA::FLIP_X) && overflow.x_overflow(); - let mut flip_y = positioner.ca.contains(CA::FLIP_Y) && overflow.y_overflow(); + let mut flip_x = positioner.ca.contains(CA_FLIP_X) && overflow.x_overflow(); + let mut flip_y = positioner.ca.contains(CA_FLIP_Y) && overflow.y_overflow(); if flip_x || flip_y { let mut adj_rel = positioner.get_position(flip_x, flip_y); let mut adj_abs = adj_rel.move_(parent_abs.x1(), parent_abs.y1()); @@ -141,14 +144,14 @@ impl XdgPopup { } } let (mut dx, mut dy) = (0, 0); - if positioner.ca.contains(CA::SLIDE_X) && overflow.x_overflow() { + if positioner.ca.contains(CA_SLIDE_X) && overflow.x_overflow() { dx = if overflow.left > 0 || overflow.left + overflow.right > 0 { parent_abs.x1() - abs_pos.x1() } else { parent_abs.x2() - abs_pos.x2() }; } - if positioner.ca.contains(CA::SLIDE_Y) && overflow.y_overflow() { + if positioner.ca.contains(CA_SLIDE_Y) && overflow.y_overflow() { dy = if overflow.top > 0 || overflow.top + overflow.bottom > 0 { parent_abs.y1() - abs_pos.y1() } else { @@ -161,11 +164,11 @@ impl XdgPopup { overflow = output_pos.get_overflow(&abs_pos); } let (mut dx1, mut dx2, mut dy1, mut dy2) = (0, 0, 0, 0); - if positioner.ca.contains(CA::RESIZE_X) { + if positioner.ca.contains(CA_RESIZE_X) { dx1 = overflow.left.max(0); dx2 = -overflow.right.max(0); } - if positioner.ca.contains(CA::RESIZE_Y) { + if positioner.ca.contains(CA_RESIZE_Y) { dy1 = overflow.top.max(0); dy2 = -overflow.bottom.max(0); } diff --git a/src/ifs/xdg_positioner.rs b/src/ifs/xdg_positioner.rs index 51b53bac..f2538d72 100644 --- a/src/ifs/xdg_positioner.rs +++ b/src/ifs/xdg_positioner.rs @@ -24,45 +24,41 @@ const BOTTOM_LEFT: u32 = 6; const TOP_RIGHT: u32 = 7; const BOTTOM_RIGHT: u32 = 8; -bitflags::bitflags! { - #[derive(Copy, Clone, Default, Debug)] - pub struct Edge: u32 { - const TOP = 1 << 0; - const BOTTOM = 1 << 1; - const LEFT = 1 << 2; - const RIGHT = 1 << 3; - } +bitflags! { + Edge: u32; + E_TOP = 1 << 0, + E_BOTTOM = 1 << 1, + E_LEFT = 1 << 2, + E_RIGHT = 1 << 3, } impl Edge { fn from_enum(e: u32) -> Option { let s = match e { - NONE => Edge::empty(), - TOP => Edge::TOP, - BOTTOM => Edge::BOTTOM, - LEFT => Edge::LEFT, - RIGHT => Edge::RIGHT, - TOP_LEFT => Edge::TOP | Edge::LEFT, - BOTTOM_LEFT => Edge::BOTTOM | Edge::LEFT, - TOP_RIGHT => Edge::TOP | Edge::RIGHT, - BOTTOM_RIGHT => Edge::BOTTOM | Edge::RIGHT, + NONE => Self::none(), + TOP => E_TOP, + BOTTOM => E_BOTTOM, + LEFT => E_LEFT, + RIGHT => E_RIGHT, + TOP_LEFT => E_TOP | E_LEFT, + BOTTOM_LEFT => E_BOTTOM | E_LEFT, + TOP_RIGHT => E_TOP | E_RIGHT, + BOTTOM_RIGHT => E_BOTTOM | E_RIGHT, _ => return None, }; Some(s) } } -bitflags::bitflags! { - #[derive(Copy, Clone, Default, Debug)] - pub struct CA: u32 { - const NONE = 0; - const SLIDE_X = 1; - const SLIDE_Y = 2; - const FLIP_X = 4; - const FLIP_Y = 8; - const RESIZE_X = 16; - const RESIZE_Y = 32; - } +bitflags! { + CA: u32; + CA_NONE = 0, + CA_SLIDE_X = 1, + CA_SLIDE_Y = 2, + CA_FLIP_X = 4, + CA_FLIP_Y = 8, + CA_RESIZE_X = 16, + CA_RESIZE_Y = 32, } pub struct XdgPositioner { @@ -98,42 +94,42 @@ impl XdgPositioned { let mut anchor = self.anchor; let mut gravity = self.gravity; if flip_x { - anchor ^= Edge::LEFT | Edge::RIGHT; - gravity ^= Edge::LEFT | Edge::RIGHT; + anchor ^= E_LEFT | E_RIGHT; + gravity ^= E_LEFT | E_RIGHT; } if flip_y { - anchor ^= Edge::TOP | Edge::BOTTOM; - gravity ^= Edge::TOP | Edge::BOTTOM; + anchor ^= E_TOP | E_BOTTOM; + gravity ^= E_TOP | E_BOTTOM; } let mut x1 = self.off_x; let mut y1 = self.off_x; - if anchor.contains(Edge::LEFT) { + if anchor.contains(E_LEFT) { x1 += self.ar.x1(); - } else if anchor.contains(Edge::RIGHT) { + } else if anchor.contains(E_RIGHT) { x1 += self.ar.x2(); } else { x1 += self.ar.x1() + self.ar.width() / 2; } - if anchor.contains(Edge::TOP) { + if anchor.contains(E_TOP) { y1 += self.ar.y1(); - } else if anchor.contains(Edge::BOTTOM) { + } else if anchor.contains(E_BOTTOM) { y1 += self.ar.y2(); } else { y1 += self.ar.y1() + self.ar.height() / 2; } - if gravity.contains(Edge::LEFT) { + if gravity.contains(E_LEFT) { x1 -= self.size_width; - } else if !gravity.contains(Edge::RIGHT) { + } else if !gravity.contains(E_RIGHT) { x1 -= self.size_width / 2; } - if gravity.contains(Edge::TOP) { + if gravity.contains(E_TOP) { y1 -= self.size_height; - } else if !gravity.contains(Edge::BOTTOM) { + } else if !gravity.contains(E_BOTTOM) { y1 -= self.size_height / 2; } @@ -218,10 +214,10 @@ impl XdgPositioner { parser: MsgParser<'_, '_>, ) -> Result<(), XdgPositionerError> { let req: SetConstraintAdjustment = self.client.parse(self, parser)?; - let ca = match CA::from_bits(req.constraint_adjustment) { - Some(c) => c, - _ => return Err(XdgPositionerError::UnknownCa(req.constraint_adjustment)), - }; + let ca = CA(req.constraint_adjustment); + if !ca.is_valid() { + return Err(XdgPositionerError::UnknownCa(req.constraint_adjustment)); + } self.position.borrow_mut().ca = ca; Ok(()) } diff --git a/src/macros.rs b/src/macros.rs index e2740362..618718dc 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -526,7 +526,7 @@ macro_rules! containing_node_impl { macro_rules! bitflags { ($name:ident: $rep:ty; $($var:ident = $val:expr,)*) => { - #[derive(Copy, Clone, Eq, PartialEq)] + #[derive(Copy, Clone, Eq, PartialEq, Default)] pub struct $name(pub $rep); $( @@ -543,18 +543,24 @@ macro_rules! bitflags { pub fn is_some(self) -> bool { self.0 != 0 } - } - impl crate::utils::bitflags::BitflagsExt for $name { - fn contains(self, other: Self) -> bool { + pub fn all() -> Self { + Self(0 $(| $val)*) + } + + pub fn is_valid(self) -> bool { + Self::all().contains(self) + } + + pub fn contains(self, other: Self) -> bool { self.0 & other.0 == other.0 } - fn not_contains(self, other: Self) -> bool { + pub fn not_contains(self, other: Self) -> bool { self.0 & other.0 != other.0 } - fn intersects(self, other: Self) -> bool { + pub fn intersects(self, other: Self) -> bool { self.0 & other.0 != 0 } } @@ -587,6 +593,12 @@ macro_rules! bitflags { } } + impl std::ops::BitXorAssign for $name { + fn bitxor_assign(&mut self, rhs: Self) { + self.0 ^= rhs.0; + } + } + impl std::ops::Not for $name { type Output = Self; diff --git a/src/pipewire/pw_ifs/pw_client_node.rs b/src/pipewire/pw_ifs/pw_client_node.rs index d4ea482b..11f47b18 100644 --- a/src/pipewire/pw_ifs/pw_client_node.rs +++ b/src/pipewire/pw_ifs/pw_client_node.rs @@ -30,8 +30,8 @@ use { }, }, utils::{ - bitfield::Bitfield, bitflags::BitflagsExt, buf::TypedBuf, clonecell::CloneCell, - copyhashmap::CopyHashMap, errorfmt::ErrorFmt, + bitfield::Bitfield, buf::TypedBuf, clonecell::CloneCell, copyhashmap::CopyHashMap, + errorfmt::ErrorFmt, }, video::dmabuf::DmaBuf, },