Skip to content

Commit

Permalink
#272 sorting out dependencies and feature flags
Browse files Browse the repository at this point in the history
  • Loading branch information
sminez committed Jul 15, 2023
1 parent 76d83a6 commit e3e97af
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 26 deletions.
17 changes: 7 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "penrose"
version = "0.3.2"
version = "0.3.3"
edition = "2021"
authors = ["sminez <innes.andersonmorrison@gmail.com>"]
license = "MIT"
Expand All @@ -23,24 +23,21 @@ members = [
]

[features]
default = ["x11rb-xcb", "keysyms"]
default = ["x11rb", "keysyms"]
keysyms = ["penrose_keysyms"]
x11rb-xcb = ["x11rb", "x11rb/allow-unsafe-code"]

[dependencies]
penrose_keysyms = { version = "0.1.1", path = "crates/penrose_keysyms", optional = true }
# penrose_proc = { version = "0.1.3", path = "crates/penrose_proc" }

anymap = "0.12"
bitflags = { version = "2.3", features = ["serde"] }
nix = "0.26"
nix = { version = "0.26", default-features = false, features = ["signal"] }
penrose_keysyms = { version = "0.3", path = "crates/penrose_keysyms", optional = true }
serde = { version = "1.0", features = ["derive"], optional = true }
strum = { version = "0.25", features = ["derive"] }
strum_macros = "0.25"
thiserror = "1.0"
tracing = { version = "0.1", features = ["attributes", "log"] }

serde = { version = "1.0", features = ["derive"], optional = true }
tracing = { version = "0.1", features = ["attributes"] }
x11rb = { version = "0.12", features = ["randr"], optional = true }
anymap = "0.12"

[dev-dependencies]
paste = "1.0.13"
Expand Down
2 changes: 1 addition & 1 deletion crates/penrose_keysyms/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "penrose_keysyms"
version = "0.1.1"
version = "0.3.3"
authors = ["IDAM <innes.andersonmorrison@gmail.com>"]
edition = "2018"
license = "MIT"
Expand Down
9 changes: 4 additions & 5 deletions crates/penrose_ui/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "penrose_ui"
version = "0.3.4"
version = "0.3.3"
edition = "2021"
authors = ["sminez <innes.andersonmorrison@gmail.com>"]
license = "MIT"
Expand All @@ -13,11 +13,10 @@ description = "UI elements for the penrose window manager library"

[dependencies]
penrose = { version = "0.3", path = "../../" }
tracing = { version = "0.1", features = ["attributes", "log"] }
tracing = { version = "0.1", features = ["attributes"] }
thiserror = "1.0"
yeslogic-fontconfig-sys = "4.0.1"
x11 = { version = "2.21.0", features = ["xft", "xlib"] }
x11rb = "0.12.0"
yeslogic-fontconfig-sys = "4.0"
x11 = { version = "2.21", features = ["xft", "xlib"] }

[dev-dependencies]
anyhow = "1.0.71"
3 changes: 1 addition & 2 deletions crates/penrose_ui/src/bar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ use penrose::{
};
use std::fmt;
use tracing::{debug, error, info};
use x11rb::protocol::xproto::ConnectionExt;

pub mod widgets;

Expand Down Expand Up @@ -240,7 +239,7 @@ pub fn event_hook<X: XConn + 'static>(

for &(id, _) in bar.screens.iter() {
info!(%id, "removing previous status bar");
bar.draw.conn.connection().destroy_window(*id)?;
bar.draw.conn.destroy_window(id)?;
}

if let Err(e) = bar.init_for_screens() {
Expand Down
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
issue_tracker_base_url = "https://github.com/sminez/penrose/issues/"
)]

#[cfg(feature = "x11rb-xcb")]
#[cfg(feature = "x11rb")]
use ::x11rb::{
errors::{ConnectError, ConnectionError, ReplyError, ReplyOrIdError},
x11_utils::X11Error,
Expand All @@ -81,7 +81,7 @@ mod macros;
pub mod pure;
pub mod util;
pub mod x;
#[cfg(feature = "x11rb-xcb")]
#[cfg(feature = "x11rb")]
pub mod x11rb;

#[doc(inline)]
Expand Down Expand Up @@ -198,27 +198,27 @@ pub enum Error {
// set of common error variants that they can be mapped to without
// needing to extend the enum conditionally when flags are enabled
/// An error that occurred while connecting to an X11 server
#[cfg(feature = "x11rb-xcb")]
#[cfg(feature = "x11rb")]
#[error(transparent)]
X11rbConnect(#[from] ConnectError),

/// An error that occurred on an already established X11 connection
#[cfg(feature = "x11rb-xcb")]
#[cfg(feature = "x11rb")]
#[error(transparent)]
X11rbConnection(#[from] ConnectionError),

/// An error that occurred with some request.
#[cfg(feature = "x11rb-xcb")]
#[cfg(feature = "x11rb")]
#[error(transparent)]
X11rbReplyError(#[from] ReplyError),

/// An error caused by some request or by the exhaustion of IDs.
#[cfg(feature = "x11rb-xcb")]
#[cfg(feature = "x11rb")]
#[error(transparent)]
X11rbReplyOrIdError(#[from] ReplyOrIdError),

/// Representation of an X11 error packet that was sent by the server.
#[cfg(feature = "x11rb-xcb")]
#[cfg(feature = "x11rb")]
#[error("X11 error: {0:?}")]
X11rbX11Error(X11Error),
}
Expand Down
13 changes: 12 additions & 1 deletion src/x11rb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ use x11rb::{
},
rust_connection::RustConnection,
wrapper::ConnectionExt as _,
xcb_ffi::XCBConnection,
CURRENT_TIME,
};

#[cfg(feature = "x11rb-xcb")]
use x11rb::xcb_ffi::XCBConnection;

pub mod conversions;

use conversions::convert_event;
Expand Down Expand Up @@ -109,9 +111,11 @@ impl Conn<RustConnection> {
}
}

#[cfg(feature = "x11rb-xcb")]
/// An C based connection to the X server using an [XCBConnection].
pub type XcbConn = Conn<XCBConnection>;

#[cfg(feature = "x11rb-xcb")]
impl Conn<XCBConnection> {
/// Construct an X11rbConnection backed by the [x11rb][crate::x11rb] backend using
/// [x11rb::xcb_ffi::XCBConnection].
Expand Down Expand Up @@ -223,6 +227,13 @@ where

Ok(id)
}

/// Destroy the window identified by the given `Xid`.
pub fn destroy_window(&self, id: Xid) -> Result<()> {
self.conn.destroy_window(*id)?;

Ok(())
}
}

impl<C> XConn for Conn<C>
Expand Down

0 comments on commit e3e97af

Please sign in to comment.