Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use x11rb instead of rust-xcb #31

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Use x11rb instead of rust-xcb #31

wants to merge 4 commits into from

Conversation

JuanPotato
Copy link
Member

I managed to typo in the commit. nice. Anyway this switches our xcb library to x11rb because it's very nice.

I tried to leave as much of the code as similar to the original as possible to make the diff easier to review.

Copy link
Member Author

@JuanPotato JuanPotato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! I would suggest running rustfmt on this too

src/lib/mod.rs Outdated Show resolved Hide resolved
src/lib/mod.rs Outdated Show resolved Hide resolved
(attrs.map_state() & xcb::MAP_STATE_VIEWABLE as u8) != 0
fn viewable<C: Connection>(conn: &C, win: xproto::Window) -> bool {
let attrs = xproto::get_window_attributes(conn, win).unwrap().reply().unwrap();
attrs.map_state == xproto::MapState::Viewable
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map_state is an enum variant so using == works instead of checking bits

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(this should probably go in a source code comment)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was an explanation for why the change is valid.

src/main.rs Outdated Show resolved Hide resolved
src/main.rs Show resolved Hide resolved
src/main.rs Show resolved Hide resolved
src/main.rs Show resolved Hide resolved
@expectocode
Copy link
Member

Looks good overall and I trust you, I'll take a deeper look in the morning.

@expectocode
Copy link
Member

and yes do rustfmt

@@ -17,15 +20,21 @@ fn min_max(a: i16, b: i16) -> (i16, i16) {
}
}

fn build_guides(screen: xcb::Rectangle, pt: xcb::Point, width: u16) -> [xcb::Rectangle; 2] {
fn build_guides(screen: xproto::Rectangle, pt: xproto::Point, width: u16) -> [xproto::Rectangle; 2] {
[
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer splitting out rectangle into their own definition first since that would make them one line IIRC.

@JuanPotato
Copy link
Member Author

Mildly related to this PR, we should probably change a fair bit of the unwraps to expects so we can have a decent error message if it crashes

src/lib/mod.rs Show resolved Hide resolved
src/lib/mod.rs Show resolved Hide resolved
src/lib/parse_format.rs Show resolved Hide resolved
src/main.rs Show resolved Hide resolved
| xproto::EventMask::StructureNotify
| xproto::EventMask::SubstructureNotify,
)
.override_redirect(1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment was lost here? "Don't be window managed"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ?RGB comment was also lost. Keypress comment isn't needed anymore since we do use the event. What does it mean to be window managed?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that the window manager doesn't manage this window

@expectocode
Copy link
Member

Mildly related to this PR, we should probably change a fair bit of the unwraps to expects so we can have a decent error message if it crashes

Yes, maybe it would be benefical for us to adopt an application-focused error library so we could easily propagate up with context. Not sure what the state of best practices is right now.

@pickfire
Copy link
Contributor

anyhow

@JuanPotato
Copy link
Member Author

I forgot about this PR

@samyak-jain
Copy link

Are there any plans to merge this? Is this PR incomplete?

@9ary
Copy link
Member

9ary commented Sep 15, 2021

There just hasn't been much motivation to complete it. It'd be nice though.

@samyak-jain
Copy link

Mildly related to this PR, we should probably change a fair bit of the unwraps to expects so we can have a decent error message if it crashes

Yes, maybe it would be benefical for us to adopt an application-focused error library so we could easily propagate up with context. Not sure what the state of best practices is right now.

Agreed. We can have something along the lines of this: https://github.com/samyak-jain/hacksaw/tree/lib but using x11rb. I'd be happy to contribute. I think as a library it probably makes sense to propogate custom error types instead of using anyhow.

@samyak-jain
Copy link

There just hasn't been much motivation to complete it. It'd be nice though.

If we have an idea on what's left to be completed. I'd be happy to help. I don't know if anyone would have the bandwidth to review it though.

@pickfire
Copy link
Contributor

The maintainers can help to review but since not all of us still use it now there may be less reviewers.

@9ary
Copy link
Member

9ary commented Sep 15, 2021

The maintainers can help to review but since not all of us still use it now there may be less reviewers.

This, I've been using sway for two years now so I can't use hacksaw anymore, so it's both lack of interest and limited ability to test for me. Can't speak for the others but I think @JuanPotato and @expectocode still use it though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants