Skip to content

Component architecture rewrite#20

Open
dogamak wants to merge 34 commits intomasterfrom
feature-8
Open

Component architecture rewrite#20
dogamak wants to merge 34 commits intomasterfrom
feature-8

Conversation

@dogamak
Copy link
Owner

@dogamak dogamak commented Jun 28, 2017

The trait Component is now split into ComponentConfig ans
ComponentState, which allows us more flexibility with the
user facing configuration types. (Eg. accepting a &str and copying it
into a String afterwards)

The ComponentState has now more methods than the previous
Component trait had, which allows for better error messages. The
render method also accepts a cairo::Surface so that components can
render arbitary visuals on the bar.

I'll create this pull request for my own commit. I have no idea if this is a common practice or not. Actually I don't have a clue about anything regarding git workflows, but this seems like a thing that could be a thing. 😕

This is a counterpart of #8. It seems like github uses the same id space for bot pull requests and issues, so I might be a little confused here...

The trait `Component` is now split into `ComponentConfig` ans
`ComponentState`, which allows us more flexibility with the
user facing configuration types. (Eg. accepting a `&str` and copying it
into a `String` afterwards)

The `ComponentState` has now more methods than the previous
`Component` trait had, which allows for better error messages. The
`render` method also accepts a `cairo::Surface` so that components can
render arbitary visuals on the bar.
@chrisduerr
Copy link
Contributor

Well like this travis seems to automatically check the builds which is nice.
Especially in situation like this where travis actually fails. It seems like it has issues resolving the dependencies.

error[E0432]: unresolved import `component::Component`
 --> src/components/pipe.rs:1:5
  |
1 | use component::Component;
  |     ^^^^^^^^^^^^^^^^^^^^ no `Component` in `component`

@dogamak
Copy link
Owner Author

dogamak commented Jun 29, 2017

Ah, I have only implemented the traits in src/component.rs and not yet ported anything to use them. Travis is expected to fail at this point.

Replace `ItemState` with `ComponentContext` and
`Box<ComponentStateExt>`.

Adresses #8
Redesing the `Component*` traits so that `ComponentState` doesn't have
to implement `Stream`.  Also modified `Bar` to use single `Vec` to
store all components and created `XcbContext` to bundle XCB related
information.  `ComponentContext` was also changed drastically.
Created `ComponentStateWrapper` to wrap `ComponentState` and the
associated stream in such a way that we can preserve full type
safety.
@dogamak
Copy link
Owner Author

dogamak commented Jul 1, 2017

  1. Come up with an idea of how stuff should work
  2. Sweat your ass of fighting the compiler that doesn't like your visions
  3. Wohoo it finally compiles
  4. Realize that it's impossible to implement something using this desing
  5. Rinse and repeat

Programming is FUN!

@chrisduerr
Copy link
Contributor

At least travis seems to like it more now. What design issues did you run into? Could you resolve them?

@dogamak
Copy link
Owner Author

dogamak commented Jul 1, 2017

Initially I required ComponentState to implement Stream (to deliver updates) for whatever reason, which meant that the stream couldn't be created in a conventional way and returned from create() or updates().

I hope I have resolved the issues successfully and that the current version has managed to improve the type safety while simplifying the interface. (Especially by cutting the number of different traits.) Now ComponentState::create returns a (Self, Self::Stream), which allows to the implementer to reuse the different streams and combinators provided in the futures crate.

Next up is implementing the abstraction layer which provides StringComponent trait for implementing components similar to what we have now.

@dogamak
Copy link
Owner Author

dogamak commented Jul 1, 2017

Also, I need an interface for a component to get the bar properties (e.g. fg/bg colors, height).

dogamak added 5 commits July 14, 2017 16:17
…ng it.

This is archieved through `ComponentContainer` wrapper enum and
`ComponentContainerExt` trait, which replaces the `ComponentConfigExt`
as the way of storing the component config before crating it.
Fix an integer overflow that occurs when rendering centered
components.
@dogamak
Copy link
Owner Author

dogamak commented Jul 14, 2017

Argh. Travis fails because of some weird PangoCairo C-binding stuff.
I don't want to deal with this shit now.. or ever really.

@chrisduerr
Copy link
Contributor

chrisduerr commented Jul 14, 2017

So dependency issues with the CI and not actual build problems?

It looks like it has nothing to do with Travis. So setting the dependency in Cargo.toml to a fixed commit will probably make this work for now. In the long run the plan is to go with crates.io anyways, right?

@dogamak
Copy link
Owner Author

dogamak commented Jul 14, 2017

I don't think any of our dependencies have updated in the last 2 months, so I think this is debian updating their glib/cairo/pango packages or something.

Also, works on my machine.

@chrisduerr
Copy link
Contributor

chrisduerr commented Jul 14, 2017

No I've just tried running cargo clean and removed the lockfile and I ran into the same issue.

Using Archlinux with latest nightly.

@dogamak
Copy link
Owner Author

dogamak commented Jul 14, 2017

Oh. After cargo clean it fails for me too. The reason seems to be this commit, but I don't know how I can resolve this as we don't directly depend on glib.

And with that cargo clean I threw away my working Cargo.lock...

@chrisduerr
Copy link
Contributor

chrisduerr commented Jul 14, 2017

Well that is kinda unfortunate. :P
This would probably require looking through the dependencies and checking what depends on dlib. It's probably the pangocairo stuff I'd say? Just trying a few different commits might help?

Unfortunately the Cargo.lock is not in git so all branches broke for me now.

@dogamak
Copy link
Owner Author

dogamak commented Jul 14, 2017

Here's your dependency graph for reference. What do you mean by "trying a few different commits"?

@chrisduerr
Copy link
Contributor

It doesn't look like this one restarted the CI.

@dogamak
Copy link
Owner Author

dogamak commented Jul 19, 2017

Well, it might be that we hit some concurrent build quota with these 16 build tasks.

@chrisduerr
Copy link
Contributor

Yeah I guess running 6 builds at the same time might be a bit much.

@dogamak dogamak closed this Jul 19, 2017
@dogamak dogamak reopened this Jul 19, 2017
@dogamak
Copy link
Owner Author

dogamak commented Jul 19, 2017

Oh right, this branch still has the old CI configs.

@chrisduerr
Copy link
Contributor

What is left to do before this can be merged? Seems like everything is fine with travis.

Split `StringComponent` into `StringComponentConfig` and
`StringComponentState` similarly to the `ComponentConfig` and
`ComponentState` traits.

This is more flexible and I should have done this to begin with. It
adds more boilerplate code when implementing trivial components, but
that can be simplified with a macro in a future if necessary.
Refactor the components to use the split up `StringComponent` traits.
@dogamak
Copy link
Owner Author

dogamak commented Aug 14, 2017

Ran into problems when trying to implement the NetworkUsage component with the StringComponent trait. Now StringComponent is split up like the ComponentConfig and ComponentState traits.

However there seems to be some issues with tokio usage. All components do not always update independently. This might be caused by prematurely returning Async::NotReady somewhere, but I couldn't find the cause.

The middle slot has BG drawing issues again, maybe I accidentally reversed something while resolving merge conflicts?

if let Some(&(ref ctx, _)) = self.slot_items(Slot::Center).first() {
if let Some(old_start) = ctx.position {
self.paint_bg(old_start, old_start + old_width_all)?;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I can't see an issue but the center problem is probably caused by the changes to redraw_center before this point.

Copy link
Contributor

Choose a reason for hiding this comment

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

@dogamak I just checked and it seems like the old_width_all is not calculated properly. Is it not possible to get the old width anymore?

Copy link
Contributor

Choose a reason for hiding this comment

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

I also found the issue that when position changes, but not width, there will be no redraw. Getting the old position works tho. So this is an oversight in my initial implementation.

@chrisduerr
Copy link
Contributor

Tokio always is a little troublesome in my experience. Might be a good idea to narrow down the issue and then ask in tokio gitter/irc.

@chrisduerr
Copy link
Contributor

One thing I also noticed is that not only the center element old width is wrong, but it also cuts off the element (only small part of it is displayed). So something's not right there.

@chrisduerr
Copy link
Contributor

@dogamak Would you accept PRs to this PR? I could look into some of these problems to get this finished already.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants