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 separate pixmaps for each edge of a container #3479

Open
Airblader opened this Issue Oct 26, 2018 · 3 comments

Comments

Projects
None yet
2 participants
@Airblader
Member

Airblader commented Oct 26, 2018

I'm submitting a…

[x] Bug
[ ] Feature Request
[ ] Documentation Request
[ ] Other (Please describe in detail)

Current Behavior

i3 uses a single pixmap that covers the entire window.

Expected Behavior

To reduce memory usage, we could use separate pixmaps for the edges (top, bottom, left right) to draw titlebar + borders, and leave the inside of the windows without a (useless) pixmap. See #2742 (comment) for details.

Environment

i3 4.15

@Airblader

This comment has been minimized.

Member

Airblader commented Oct 26, 2018

One thing to look out for is corners, which need to be assigned to one of the edges. The upper two corners can probably easily be assigned to the top edge, but for the lower corners we might have to be more careful because of things like the split indicator.

@psychon

This comment has been minimized.

psychon commented Oct 26, 2018

Assuming you are fine with depending on cairo's tee surface support (IIRC this is not enabled by default in cairo), you could create a "virtual cairo surface with holes" to draw to:

A tee surface contains a list of other cairo surfaces. Each drawing operation on the tee surface is done to all the underlying surfaces.

For each of the four pixmaps, you create a cairo surface. You use cairo_surface_set_device_offset() to move the (0,0) point of this surface so that all these surfaces have "the right" coordinate system (i.e. the surface for the bottom edge only has its surface-local (0,0) appear at something like (0,height)). Then, you create a tee surface from all of these individual surfaces and just keep your existing code for drawing, but draw to the tee surface.

No idea if this works correctly (I wouldn't be surprised if cairo had bugs in this area, partly because this would explain why tee surfaces are not enabled by default). But if this works, it would be the least invasive change to the existing drawing code. Plus, the existing drawing code itself would not become more complicated.

(The alternative would be to not use a tee surface, but instead run the existing drawing code four times, once for each of the sub-surfaces)

@Airblader

This comment has been minimized.

Member

Airblader commented Oct 26, 2018

That's a really interesting concept and would be cool to use, but if it's not enabled by default, we'd at least need a fallback to the current approach. And even then I guess it's only worth the (even if less) effort if it's enabled »somewhere«. :-)

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