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

Separate logic into crate? #6

Closed
jD91mZM2 opened this issue Nov 7, 2017 · 9 comments
Closed

Separate logic into crate? #6

jD91mZM2 opened this issue Nov 7, 2017 · 9 comments

Comments

@jD91mZM2
Copy link

jD91mZM2 commented Nov 7, 2017

Hey! This looks really cool! Any chance you could separate the logic to a separate crate so people could use it in their own applications?

@9ary
Copy link
Member

9ary commented Nov 7, 2017

Thanks for the compliment and suggestion. This doesn't sound like a bad idea at all, I'll look into it when I can.

@9ary
Copy link
Member

9ary commented Nov 7, 2017

I'll need more details on what you actually expect from the separate crate. I've glanced at my code, and most of the logic is for processing user input. The rest is a very thin wrapper around Xlib, and copying buffers around.
What interface should I provide? I'm thinking of letting the consumer open the X connection themselves, then calling a single function with optional window ID and geometry, which then returns the screenshot as an image::RgbaImage.

@jD91mZM2
Copy link
Author

jD91mZM2 commented Nov 8, 2017

I imagined something high-level like

let mut display = Display::new(":0");
let image = display.capture_window(<id>); // returns struct with: width, height and byte vec

(But it's completely up to you)

@pickfire
Copy link
Collaborator

Any news on this?

@9ary
Copy link
Member

9ary commented Mar 26, 2020

Well as I've said before, I'm not sure what kind of API I should provide. The problem is more complex than the proposition above, but also still trivial enough to make a library crate unnecessary. I think the best I could do would be exposing the same parameters as the command-line interface, and returning a struct from the Image crate, but that's a major refactoring.

Another major blocker is that I don't use shotgun anymore, as I've switched to Wayland, and I'm not interested in doing this either way. I will gladly review a pull request implementing the above though.

@pickfire
Copy link
Collaborator

@9ary Oh, why did you switched to wayland? Which wayland do you use? Do you have any issues? How was it?

@9ary
Copy link
Member

9ary commented Mar 26, 2020

I'm using sway. The main motivation was extremely poor performance and a buggy experience with Intel graphics on my laptop, as well as the lack of a good compositor for X. sway solves all of this.
Wayland in general is a much better protocol than X11, which was not designed for modern hardware and has accumulated a lot of cruft which is difficult to keep working well and modernize.

@pickfire
Copy link
Collaborator

@9ary Ah, I am interested to hear more, I also use Intel on my side. Let's take this offline, maybe on telegram chat later.

@jD91mZM2
Copy link
Author

I'll close this as you're right, the crate might be too small if you extract out all argument handling

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

No branches or pull requests

3 participants