Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(render): support pseudo-transparency#595

Merged
patrick96 merged 17 commits into
polybar:masterfrom
bennofs:feat-pseudo-transparency
Oct 4, 2018
Merged

feat(render): support pseudo-transparency#595
patrick96 merged 17 commits into
polybar:masterfrom
bennofs:feat-pseudo-transparency

Conversation

@bennofs

@bennofs bennofs commented May 23, 2017

Copy link
Copy Markdown
Contributor

Changelog Note:
This deprecates the tray-transparent key and adds the settings.pseudo-transparency key.
The tray always uses pseudo-transparency, while the bar only uses it when activated.
/Changelog Note

This adds pseudo-transparency for the background of the bar and the
background of the systray.

Here's how it lools (systray is on the right edge, after the power symbol):

pic

I've submitted the PR now to get some feedback on the general implementation, there's still a few small cleanup tasks to do:

  • Cleanup tray changes
  • Check behaviour with compositing enabled.

Fixes #382

@bennofs

bennofs commented Jul 11, 2017

Copy link
Copy Markdown
Contributor Author

@jaagr any comments?

@jaagr

jaagr commented Jul 14, 2017

Copy link
Copy Markdown
Member

@beenofs sorry for my extreme delay. I have a few comments, will open up a review as soon as I can.

@bennofs

bennofs commented Jul 14, 2017

Copy link
Copy Markdown
Contributor Author

@jaagr no problem, take your time. Just wanted to make sure this didn't get lost, as I often forget about PRs myself when I only take a short look at them and then github notification is gone ☺

@lmoesch

lmoesch commented Aug 30, 2017

Copy link
Copy Markdown

This feature is currently not compatible with a bottom aligned bar.

@bennofs

bennofs commented Aug 30, 2017

Copy link
Copy Markdown
Contributor Author

@lmoesch oh? what happens in that case? i had assumed that m_rect would be the correct rect for a bottom alligned bar as well

@lmoesch

lmoesch commented Aug 30, 2017

Copy link
Copy Markdown

The background area is still copied from the top of the background, not the bottom. I tried to modify the values of "copy_area_checked" within the background_manager wich did the trick. So basically we need to get the corner point information to that function.

@bennofs

bennofs commented Aug 30, 2017

Copy link
Copy Markdown
Contributor Author

@lmoesch background_manager stores a m_rect that specifies the target location from which the background should be copied. It is passed to it in via the activate method, so we just need to make sure we pass it the right values there.

@bennofs bennofs force-pushed the feat-pseudo-transparency branch from 299f371 to bfb1539 Compare August 30, 2017 16:12
@bennofs

bennofs commented Aug 30, 2017

Copy link
Copy Markdown
Contributor Author

@lmoesch should be fixed with last commit.

(needed to use m_bar.inner_area(true) instead of m_bar.inner_area())

@lmoesch

lmoesch commented Aug 30, 2017

Copy link
Copy Markdown

Splendid, that worked like a charm! Thanks for the quick fix 👍

@lmoesch

lmoesch commented Aug 31, 2017

Copy link
Copy Markdown

While fiddeling arround with some parameters I came across other bugs.

First thing is, that the offset of a border is not taken into account while calculating the background snippet. Unfortunately I have just few to no knowledge about X-Server classes and behaviour, but I assume that a border is also drawn by a rectangle which gets overdrawn by the content. So to fix this one I guess it is sufficient to replace the bar rectangle with the border rectangle.

Other thing is a trickey one. When using multiple bars ontop of each other, background location also fails due to the offset to each other. (e.g. if you have two bars on top, then both will have the background of the most upper one)

@bennofs

bennofs commented Aug 31, 2017

Copy link
Copy Markdown
Contributor Author

@lmoesch

Borders work correctly now: (this is a semi-transparent border at top)

polybar

Have to look into the "multipe bars stacked" issue.

@bennofs bennofs force-pushed the feat-pseudo-transparency branch from 92b001b to dd3b100 Compare August 31, 2017 13:16
@bennofs

bennofs commented Aug 31, 2017

Copy link
Copy Markdown
Contributor Author

Btw, I am not sure anymore what I originally meant by "Cleanup tray changes"

@bennofs

bennofs commented Aug 31, 2017

Copy link
Copy Markdown
Contributor Author

Ok, fixed the second issue as well:

polybar

Hope I haved missed any configuration :)

@bennofs

bennofs commented Dec 20, 2017

Copy link
Copy Markdown
Contributor Author

Rebased against latest master

@NBonaparte NBonaparte left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

It looks like it mostly works. I've tested with borders and it functions correctly, except for the tray which does not function properly (gives a solid color). I have not tried stacking trays yet.

From what I see pseudo-transparency is always used including with compositors; I'm assuming you're planning to create some detection method?

Comment thread include/x11/background_manager.hpp Outdated

xcb_visualtype_t* m_visual = nullptr;
xcb_gcontext_t m_gcontext = XCB_NONE;
xcb_pixmap_t m_pixmap = XCB_NONE;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For these as well as m_attached could you use brace initialization to be consistent with the rest of the code?

Comment thread src/components/parser.cpp Outdated
switch (tag) {
case 'B':
m_sig.emit(change_background{parse_color(value, bar.background)});
m_sig.emit(change_background{parse_color(value, 0x0)});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this set to 0x0?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is because 0 specifes "fully transparent": the bar background is now handled in the renderer by compositing everything on top of a surface filled with the background using cairo. So to use "background color" we can simply use "transparent".

@bennofs

bennofs commented Dec 21, 2017

Copy link
Copy Markdown
Contributor Author

Thanks for the review!

I have changed to using brace initialization. The tray works fine for me, but alpha support in the tray is dependent on the tray icon having alpha channel I think. What program have you tried, maybe it is specific to that program that it does not work (does it work if using a compositor)? I am using udiskie which has a tray icon and that it works there for me.

Yes we need a detection method. I will look into that. But with the changes, it should be pretty easy to turn of the pseudo-transparency if there is a compositor: right now, we fill the surface with the desktop background as a first step and then paint everything on top of that, using cairo's support for transparency. If we have a compositor, we can simply drop the first step and paint the window fully transparent, everything else should keep working.

@NBonaparte

Copy link
Copy Markdown
Member

I've tried nm-applet and yakyak (an Electron app) and both result in an opaque background, with and without compton.

@bennofs

bennofs commented Dec 21, 2017

Copy link
Copy Markdown
Contributor Author

@NBonaparte hmm, if I use the example config and change background to #BB222222 everything is semi-transparent for me. Were you using tray-background?

@bennofs

bennofs commented Dec 21, 2017

Copy link
Copy Markdown
Contributor Author

It works for me even when using tray-background (if tray-background is set, it takes precendence over background and is used instead of it) or tray-transparent (which will cause the tray to become 100% transparent)

@NBonaparte

Copy link
Copy Markdown
Member

I tried with and without tray-background, and it just gives me an opaque color. With #BB222222 I get the color #191919.

@bennofs

bennofs commented Dec 21, 2017

Copy link
Copy Markdown
Contributor Author

What window manager, desktop, distribution are you using? You're using the default config except for changing the background color, right? I can't reproduce this here.

@NBonaparte

Copy link
Copy Markdown
Member

Using bspwm, Arch Linux, default config with background = #BB222222 results in this:
2017-12-21-150845_53x27_scrot

@bennofs

bennofs commented Dec 21, 2017

Copy link
Copy Markdown
Contributor Author

Hmm, are you setting a background image? I use feh --bg-fill /path/to/desktop/background.jpg

@NBonaparte

Copy link
Copy Markdown
Member

Yeah, using nitrogen. The rest of the bar looks like
2017-12-21-151734_1920x35_scrot

@patrick96

Copy link
Copy Markdown
Member

Awesome! I think we're done. I'm going to wait a week on NBonaparte's for feedback but after that we'll merge this.

@patrick96 patrick96 dismissed NBonaparte’s stale review October 4, 2018 13:38

Everything was addressed

@patrick96 patrick96 merged commit 13b0ee7 into polybar:master Oct 4, 2018
@patrick96

Copy link
Copy Markdown
Member

After only 17 months we have finally merged this!

@bennofs, thank you so much for all your hard work, we really appreciate it. This is a really exciting feature to have!

Would you be available to help out if problems arise with this feature?

@bennofs

bennofs commented Oct 5, 2018

Copy link
Copy Markdown
Contributor Author

Thanks! You can ping me in any issues related to this.

@bennofs bennofs deleted the feat-pseudo-transparency branch October 5, 2018 06:54
@patrick96

Copy link
Copy Markdown
Member

Awesome! Let's hope we won't need to ;)

@Banbeucmas

Copy link
Copy Markdown

@patrick96 @bennofs Finally, congratulations.

@kingkobra87

Copy link
Copy Markdown

Thank you so much for this!

@fominv

fominv commented Oct 8, 2018

Copy link
Copy Markdown

Thank you guys for your work!

@pabloariasal

Copy link
Copy Markdown

Thank you so much for this!! @bennofs you are amazing!

@Phaenyxx

Phaenyxx commented Dec 22, 2018

Copy link
Copy Markdown

Looks like setting an offset x value for the tray breaks the transparency :
image

patrick96 added a commit that referenced this pull request Dec 23, 2018
### Breaking Changes:
None

### Changelog

**New Config Options**
The following config options were added

In the `[settings]` section:
* `pseudo-transparency`

In `internal/cpu`:
* `ramp-coreload-spacing`, spacing between elements in `<ramp-coreload>` elements
* `%percentage-sum%` in `label`. Shows sum of all percentages

In `custom/script`:
* `double-click-left`
* `double-click-middle`
* `double-click-right`

In `internal/pulseaudio`:
* `interval`, volume increase and decrease steps in percentage points

In `internal/memory`:
* `bar-swap-used`
* `bar-swap-free`
* `ramp-swap-used`
* `ramp-swap-free`

**Deprecations**
* `tray-transparent` in the bar section is no longer used. The tray now always uses pseudo-transparency

**Features**
* volume: adjustable volume steps (#1364), see #1361
* memory: Add progress bars and ramps for swap (#1325)
* render: pseudo-transparency (always used in the tray)  (#595)
* cpu: 
    * Configurable spacing in between coreloads (#1472), see #1389
    * Non-normalized cpu load (#1517), see #1516
* script: Double click actions (#1442)
* net: Support for bridge interfaces (#1528), see #1522
* token: zero pad tokens when min-width value starts with a `0` (#1341), see #1332

**Fixes**
* config: Use font patterns detected on system in sample config (#1350)
* net: Disconnected module when SSID is only an emoji (#1371), see #1367
* tray: Tray overlapping with bar (#1392), see #591
* build: Several build errors (#1395, #1454, #1470, polybar/xpp#12, #1493), see #1447, #1469, #750, #1492
* mpd: format-online-prefix not working (#1402), see #1399
* font: Crash for some font-patterns (#1451), see #1435
* script: 
    * Only `%counter%` or `%pid%` token usable, never both (#1456)
    * click actions with colons in them (#1457), see #984
* renderer: Bar locks up when xorg composite extension is disabled (#1430), see #1425
@patrick96

Copy link
Copy Markdown
Member

Can confirm. @bennofs any idea how to fix this? I was able to get transparency back by adding the offset to both the x and y arguments here (cairo_set_source_surface(*m_context, *surface, -x, -y);). But that gives me the background of wherever the tray would be without offset. Is it even possible to get the background for areas that are not covered by the bar?

@bennofs

bennofs commented Dec 28, 2018

Copy link
Copy Markdown
Contributor Author

I will look into this when I have time (probably right after new year, possibly earlier)

@patrick96

Copy link
Copy Markdown
Member

No rush :)

@bennofs

bennofs commented Jan 1, 2019

Copy link
Copy Markdown
Contributor Author

Looks like setting an offset x value for the tray breaks the transparency : example

The example file seems to have gone away. Can you restore it / upload to github?

@patrick96

Copy link
Copy Markdown
Member

@bennofs Also, here's a config with which I can reproduce the issue:

[bar/example]
width = 90%
height = 40
radius = 20.0

bottom = true

background = #99000000
foreground = #dfdfdf

border-size = 4
border-color = #dd000000

padding-left = 0
padding-right = 2

modules-left = title

tray-position = right
tray-padding = 2
tray-background = ${self.background}
tray-offset-x = 20
tray-offset-y = -20

[module/title]
type = internal/xwindow

[settings]
pseudo-transparency = true

; vim:ft=dosini

@bennofs

bennofs commented Jan 1, 2019

Copy link
Copy Markdown
Contributor Author

Ok. What exactly is the intended behaviour of that? The space that is "left over" due to the x/y movement should be filled with the bar's background as well?

@patrick96

Copy link
Copy Markdown
Member

I think the intended behavior should be that the whole tray has a transparent background even the parts that do not overlap the bar window.

I think the gap that the tray leaves doesn't need to be filled.

@bennofs

bennofs commented Jan 2, 2019

Copy link
Copy Markdown
Contributor Author

Should be fixed by #1571

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.