chjj / compton

A compositor for X11.
Other
2.25k stars 500 forks source link

[feature request] Shadows for active window #64

Closed BenoitZugmeyer closed 11 years ago

BenoitZugmeyer commented 11 years ago

I'd like to use compton to draw darker shadows under active windows. You already handle opacity for active / inactive windows, maybe it could be done the same way?

I'll try to implement this but I have no knowledge in window composition...

richardgv commented 11 years ago
  1. This is possible. This is easy to implement. Hmm, a matter of a few lines, I believe?
  2. I do not know how it could be useful. And I'm a super stubborn person in maintaining the purity of the program. :-D I would be more than glad if you could show me how this could be beneficial for you.
  3. People will then ask me for inactive window shadow radius, active window shadow radius, inactive window shadow color, active window shadow color, inactive window shadow offset, active window shadow offset, inactive window fading speed, active window fading speed, inactive window frame opacity, active window frame opacity... Seriously, I'm a bit worried about how I should answer if somebody asks for those. :-D
  4. By the way, the opacity of the shadow depends on the opacity of the window. If you enable -i(inactive-opacity), the active window will get darker shadow than the inactive.
BenoitZugmeyer commented 11 years ago

I am using Awesome WM. The focused window is currently identified by its border color.

I managed to hack a little bit in Awesome code to add a gap between windows, so I can use compton to draw drop shadows behind it (beautiful effect).

Now, I would like to remove the windows border, and identify the currently focused window with another type of drop shadow. I could use the opacity for this, but I prefer opaque windows... what do you think?

richardgv commented 11 years ago

@BenoitZugmeyer:

Sorry, BenoitZugmeyer, I can't comprehend why you would get the idea to identify whether a window is focused using shadow. For me shadow opacity is just too unnoticeable to be used for the purpose.

But, well, sometimes my ideas can't be comprehended by others, too. So here's a patch to add support for what you want: https://gist.github.com/4131170

It must be applied on code of richardgv-dev branch currently. Fetch it, apply the patch, build it, and use it in this way:

# Inactive windows have 50%-transparent shadows, active windows have
# whatever you have selected as default.
compton -c --inactive-shadow-opacity 0.5

It's unlikely that it will get into the repo, unfortunately, until you could presuade me, or I see other user coming for the same thing.

BenoitZugmeyer commented 11 years ago

Thank you very much, I'll try this soon. Maybe you're right, it may not be enough... anyway, I'll post a screenshot if it looks good.

BenoitZugmeyer commented 11 years ago

Well you was right, the distinction is too small to be usable. In the meantime, I found the --inactive-dim option, which provide a good way to identify focused window without changing the opacity.

Thanks for your time and your great work!

lingnand commented 11 years ago

I actually would like to have the same feature. I feel this would be quite useful if you are using a tiling window manager. Say you have a set of tiled windows occupying all the space on the desktop; a shadow on the active window would make that tile stand out as spatially that feels like it's stacked higher than all other tiles. Combining this effect with the fading effect would be really great visually for a user to distinguish the active window from others.

However to make this really work I feel that the shadow needs to be in all directoins. Currently compton seems to render shadow at a fixed angle for a ray coming from top left to bottom right; if we have shadows in all directions then that will be similar to have a border around the window.

I'm trying to illustrate my idea with an image; it's not exactly shadow around the tile in the image below (or indeed it's just white-colored shadow), but it roughly shows the effect I'm hoping for. tiles

richardgv commented 11 years ago

@yulan6248:

I actually would like to have the same feature. I feel this would be quite useful if you are using a tiling window manager. Say you have a set of tiled windows occupying all the space on the desktop; a shadow on the active window would make that tile stand out as spatially that feels like it's stacked higher than all other tiles. Combining this effect with the fading effect would be really great visually for a user to distinguish the active window from others.

So, two men, BenoitZugmeyer and me, think this is not helpful, while only you think it's useful. 2 vs. 1, you can't win. :-D

Okay, I was just kidding. With the introduction of new condition format, there's a cheap alternative right now, to disable shadow on all inactive windows:

compton --shadow-exclude '!focused'

If you really must adjust the shadow radius instead of turn off shadow entirely depending on focus state, then, I'm afraid you would have to try to port the patch above yourself. Currently we do not have a plan to officially support this.

However to make this really work I feel that the shadow needs to be in all directoins. Currently compton seems to render shadow at a fixed angle for a ray coming from top left to bottom right; if we have shadows in all directions then that will be similar to have a border around the window.

Shadow is equally rendered on all four directions, but due to the default shadow offset it gives you an impression that it isn't. By adjusting -l (shadow-offset-x) or -t (shadow-offset-y) you could get a fair shadow or make it cast in another direction. The size of the shadow on one side is 1.5 * shadow-radius, so if your shadow-radius is 7, -l -10 -t -10 will give you equal shadow on all four directions.

lingnand commented 11 years ago

That's really fast and helpful information right there I have to say :+1: Your solution works, but I've got a new problem - the shadow for a window lower in the stack is hidden behind a neighbouring window which is higher in the stack. Is there anyway that would make shadow in front of any window (and just behind the current one of course)

richardgv commented 11 years ago

@yulan6248:

Your solution works, but I've got a new problem - the shadow for a window lower in the stack is hidden behind a neighbouring window which is higher in the stack. Is there anyway that would make shadow in front of any window (and just behind the current one of course)

No, I'm afraid this is not possible. Shadow of a lower thing will appear behind a higher one, that is how it works since the beginning of the world, and when we disobey this rule we may get many things broken. You may configure your WM to raise the active window, add some sort of margin between windows, or make the inactive window transparent, though.

lingnand commented 11 years ago

Yes I guess you are right. I was thinking more of a traditional WM - when I activate a window, that window is actually brought to the front and that's why its shadow is above all others. But in XMonad, which is the WM I'm using right now, that rule only applies to floating windows. I'd need to research online to hack XMonad to do it; or else I might just leave it as is. Thanks a lot for your help though, I feel that I've learnt more of compton's options, and my current setup is definitely more pleasing to my eyes.

Gminded commented 10 years ago

Different shadows for active and inactive windows would be a nice feature. I want to say something to support it, because I think it would be useful. With configurable shadows' opacity and radius, it would be possible to define very noticeable shadows for the active window, and little shadows for inactive windows. This by itself may be not sufficient to visually distinguish active and inactive windows, but it helps. This is exactly what's done in OS X: the active window has a stronger shadow. I know that OS X is not perfect and emulating may not be beneficial, but its looks are quite popular, so it may be a worthy addition. The configuration could stay rather simple, and a switch and safe defaults can do a lot to avoid confusion for the user. These are just my thoughts and I wanted to write them down. Keep up the good work!

jonlap commented 10 years ago

I too would like to see different shadows for active and inactive windows. Different color to be more exact. I'm not that fond of active/inactive transparency and have mostly several urxvt windows open, so this would both look good and efficiently distinguish active window from inactive ones. I'm aware it's possible to set my current window manager to change active window border to a different color, but it looks quite bland imo :) Another neat trick could be if the shadow color would be inherited from the windows border color, but I doubt it's possible.