Bug 399757 - Can AWC use buttons style from the current Window decoration?
Summary: Can AWC use buttons style from the current Window decoration?
Status: RESOLVED NOT A BUG
Alias: None
Product: Active Window Control
Classification: Plasma
Component: General (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR wishlist
Target Milestone: ---
Assignee: Chris Holland
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-13 14:14 UTC by trmdi
Modified: 2018-11-06 05:50 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
animation (42.44 KB, video/mp4)
2018-11-01 16:27 UTC, trmdi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description trmdi 2018-10-13 14:14:59 UTC
For example, can it use the buttons style from BreezeEnhanced ?
Comment 1 Chris Holland 2018-10-13 14:47:26 UTC
No, because Breeze, SierraBreeze, and BreezeEnhanced manually draw the buttons using C++. The downloadable themes use the aurorae engine which simply draws an svg. IIRC, AWC autodetects and uses those svgs, but needs to bundle svgs for breeze and breeze-dark:

https://github.com/KDE/plasma-active-window-control/tree/master/package/contents/icons

While someone could add custom svgs for BreezeEnhanged, it would not use the "hover" effect.
Comment 2 trmdi 2018-10-14 03:52:11 UTC
Is it possible with buttons written in qml?
Comment 3 Chris Holland 2018-10-14 05:10:38 UTC
Originally I was thinking we could maybe recreate the buttons in QML, as it's just a simple rectangle with rounded corners (to make a circle) that's centered with a simple zoom animation on the width/height.

But you know... it might be worth looking into the Window Decoration KCM. As it was converted to QML. The buttons animated there too on hover.

* https://github.com/KDE/kwin/tree/master/kcmkwin/kwindecoration
* https://github.com/KDE/kwin/blob/master/kcmkwin/kwindecoration/qml/Buttons.qml


We can get it to draw a non-animated button with:
https://gist.github.com/Zren/40f657da96e4d8a29b13d74b74e956c5

Unfortunately, it's not animated, since the KDecoration.Button is used for the "button editor".

The complete animated decoration previews could be picked apart somehow to get just the left side buttons + animated.

* https://github.com/KDE/kwin/blob/master/kcmkwin/kwindecoration/declarative-plugin/previewitem.cpp
* https://github.com/KDE/kwin/blob/master/kcmkwin/kwindecoration/declarative-plugin/previewbutton.cpp


We'd probably need to send the mouse events somehow.
* https://github.com/KDE/kwin/blob/master/kcmkwin/kwindecoration/declarative-plugin/previewitem.cpp#L361
Comment 5 Michail Vourlakos 2018-10-19 11:39:35 UTC
I am in the process to play with AWC in order to support Colorize effect properly in Latte Dock. I am describing this: https://www.youtube.com/watch?v=JVbIuZp3VFQ

Latte is going to provide a new way for applets in order to be informed about a new colors palette in order to paint themselves more appropriate when the colorize effect is applied.

AWC is going to be the play thing for me... In that way the window icon is not going to be colorized monochromatic and the highlights effects will fit in without breaking the coloring experience.

After that I thought that window buttons is also of such case, the window buttons are also updating their appearance based of the current window color scheme in Breeze window theme...

I am thinking how we could do that... Adjust the kcmkwin code for AWC needs and if it is possible to pass also the color scheme value for themes that support it...
Comment 6 Michail Vourlakos 2018-10-19 11:44:25 UTC
(In reply to trmdi from comment #4)
> Or could we use the code of Aurorae? 
> 
> https://github.com/KDE/kwin/blob/ea05ac380b42a0009c7a69a84ea4a5b872c3db99/
> plugins/kdecorations/aurorae/src/qml/DecorationButton.qml

if we manage to support PreviewItem and DecorationButton properly then aurorae themes will be shown correctly just like they do in kcmkwin
Comment 7 trmdi 2018-10-19 12:22:06 UTC
It will be much easier if you ask Kwin devs.
Comment 8 Michail Vourlakos 2018-10-19 12:27:36 UTC
(In reply to trmdi from comment #7)
> It will be much easier if you ask Kwin devs.

I think I found it and it can be done...
https://github.com/KDE/kwin/blob/master/kcmkwin/kwindecoration/declarative-plugin/previewclient.cpp#L39

this is how default scheme is applied and this can be altered in plugin level...

1. First thing to do is to move the kcm win decoration c++ code under AWC and make it work with AWC...
2. Afterwards anything that is not needed can be removed
3. make that palette option accessible from qml just like is doing for example at: https://github.com/KDE/kwin/blob/master/kcmkwin/kwindecoration/qml/Previews.qml#L84
Comment 9 Michail Vourlakos 2018-10-20 08:06:12 UTC
> It will be much easier if you ask Kwin devs.

ok achieved... ;) based on Chris Holland investigation which was fantastic!!

AWC in transparent latte panel:

Breeze: https://drive.google.com/file/d/1NTAaKe-lnMWwm0kNZcQLaDhlkRROiccn/view?usp=sharing

and we can define the colorscheme in whatever suits us that means that Latte can have always beautiful painting with it

SierraBreeze: https://drive.google.com/file/d/1wsVAU2qgo_guGR4LKCyMiUyoZMijFbct/view?usp=sharing


How this was achieved:

1. Moved the kcm decoration previews... code under AWC umbrella in its plugin...
2. I adjusted the previews... classes to not draw shadows etc.. because it isnt needed and simplifys the calculations
3. I sent through PreviewButton the mouse events to its m_button (Decoration2::DecorationButton)
4. I updated the PreviewButton to be colored when the m_button changes its flags isPressed and isHovered
5. I found a possible bug in Decoration2::DecorationButton that was ignoring some mouse events and hacked it through PreviewButton sending always mouse positions that are treated as valid from Decoration::DecorationButton

I dindnt find a way for aurorae themes to draw DecorationButton(s) but I might be missing something, I tried to set for Bridge:
plugin="org.kde.kwin.aurorae"
theme="Arc"

but even though Arc is in the system, it couldnt find it...
Comment 10 trmdi 2018-10-20 08:41:08 UTC
Brilliant! Can it also work with BreezeEnhanced? https://github.com/tsujan/BreezeEnhanced
Comment 11 Chris Holland 2018-10-20 08:45:16 UTC
It's theme="__aurorae__svg__Adapta"

Look at ~/.config/kwinrc

[org.kde.kdecoration2]
library=org.kde.kwin.aurorae
theme=__aurorae__svg__Adapta
Comment 12 Michail Vourlakos 2018-10-20 09:15:56 UTC
(In reply to trmdi from comment #10)
> Brilliant! Can it also work with BreezeEnhanced?
> https://github.com/tsujan/BreezeEnhanced

it works with all c++ decorations including BreezeEnhanced but the decorations should take care how they will be painted when animations are disabled. Try to disable BreezeEnhanced animations from its settings and you will notice that it doesnt provide on hovering painting for minimize/mazimized/close buttons
Comment 13 Michail Vourlakos 2018-10-20 09:17:26 UTC
(In reply to Chris Holland from comment #11)
> It's theme="__aurorae__svg__Adapta"
> 
> Look at ~/.config/kwinrc
> 
> [org.kde.kdecoration2]
> library=org.kde.kwin.aurorae
> theme=__aurorae__svg__Adapta

it doesnt work, you can test it with your example code...

I suppose Aurorae engine does not provide creating individual buttons and painting them individually. It supports only painting the entire decoration.
Comment 14 trmdi 2018-10-20 09:20:16 UTC
(In reply to Michail Vourlakos from comment #12)
> (In reply to trmdi from comment #10)
> > Brilliant! Can it also work with BreezeEnhanced?
> > https://github.com/tsujan/BreezeEnhanced
> 
> it works with all c++ decorations including BreezeEnhanced but the
> decorations should take care how they will be painted when animations are
> disabled. Try to disable BreezeEnhanced animations from its settings and you
> will notice that it doesnt provide on hovering painting for
> minimize/mazimized/close buttons

It means the animated effect on hovering the buttons is not possible?
Comment 15 Michail Vourlakos 2018-10-20 09:23:34 UTC
(In reply to trmdi from comment #14)
> (In reply to Michail Vourlakos from comment #12)
> > (In reply to trmdi from comment #10)
> > > Brilliant! Can it also work with BreezeEnhanced?
> > > https://github.com/tsujan/BreezeEnhanced
> > 
> > it works with all c++ decorations including BreezeEnhanced but the
> > decorations should take care how they will be painted when animations are
> > disabled. Try to disable BreezeEnhanced animations from its settings and you
> > will notice that it doesnt provide on hovering painting for
> > minimize/mazimized/close buttons
> 
> It means the animated effect on hovering the buttons is not possible?

it isnt, only way for animated effects to work with individual created buttons is animations flags etc. to be officially supported from KDecoration2::DecorationButton class.
Comment 16 trmdi 2018-10-20 09:30:45 UTC
(In reply to Michail Vourlakos from comment #15)
> (In reply to trmdi from comment #14)
> > (In reply to Michail Vourlakos from comment #12)
> > > (In reply to trmdi from comment #10)
> > > > Brilliant! Can it also work with BreezeEnhanced?
> > > > https://github.com/tsujan/BreezeEnhanced
> > > 
> > > it works with all c++ decorations including BreezeEnhanced but the
> > > decorations should take care how they will be painted when animations are
> > > disabled. Try to disable BreezeEnhanced animations from its settings and you
> > > will notice that it doesnt provide on hovering painting for
> > > minimize/mazimized/close buttons
> > 
> > It means the animated effect on hovering the buttons is not possible?
> 
> it isnt, only way for animated effects to work with individual created
> buttons is animations flags etc. to be officially supported from
> KDecoration2::DecorationButton class.

Is it easily to get that support?
Comment 17 Michail Vourlakos 2018-10-20 09:33:28 UTC
(In reply to trmdi from comment #16)
> (In reply to Michail Vourlakos from comment #15)
> > (In reply to trmdi from comment #14)
> > > (In reply to Michail Vourlakos from comment #12)
> > > > (In reply to trmdi from comment #10)
> > > > > Brilliant! Can it also work with BreezeEnhanced?
> > > > > https://github.com/tsujan/BreezeEnhanced
> > > > 
> 
> Is it easily to get that support?

no idea and I dont know if it would be accepted from kwin developers as accepted functionality.
Comment 18 trmdi 2018-10-20 09:36:17 UTC
But Kwinkcm preview is still able to display the animation. Can you do anything more?
Comment 19 Michail Vourlakos 2018-10-20 09:48:33 UTC
(In reply to trmdi from comment #18)
> But Kwinkcm preview is still able to display the animation. Can you do
> anything more?

they are not relevant.
The kcm is painting the entire decoration and this is why animations are supported.
I opened also this one: https://phabricator.kde.org/T9899 in case any kwin developer can provide any feedback
Comment 20 Chris Holland 2018-10-20 09:51:33 UTC
Oops. Sorry, you're right that the individual button preview doesn't work in my first gist. I was testing with my second test that 


https://gist.github.com/Zren/ce58e1b70693e9709160110828d04c44

Breeze: https://i.imgur.com/p2EzzMM.png
Adapta: https://i.imgur.com/9Q7kPx8.png
Comment 21 Michail Vourlakos 2018-10-20 14:21:45 UTC
(In reply to Chris Holland from comment #20)
> 

Chris because there is a discussion about forking AWC / maintaining etc... As I see that we both are interested to keep it alive and evolve, if the main developer does not have any issue would you like to keep it alive together?

We can pair review each other if that is the issue in order to commit through phabricator...
Comment 22 Chris Holland 2018-10-20 15:02:11 UTC
> 3. I sent through PreviewButton the mouse events to its m_button 

Could you share your previewbutton.cpp/.h via a gist.
Comment 23 Michail Vourlakos 2018-10-20 17:23:38 UTC
I will try to fully upload it in a branch when I get back home
Comment 24 Michail Vourlakos 2018-10-20 21:09:42 UTC
(In reply to Chris Holland from comment #22)
> > 3. I sent through PreviewButton the mouse events to its m_button 
> 
> Could you share your previewbutton.cpp/.h via a gist.

sorry couldnt find a better way. You can download the AWC version with: https://drive.google.com/file/d/1nNo3Mp6BeRJrrhF5KssHZM468IdrY8PP/view?usp=sharing

it draws directly two Breeze buttons in the left side of AWC
Comment 25 trmdi 2018-10-21 17:35:44 UTC
(In reply to Michail Vourlakos from comment #19)
> they are not relevant.
> The kcm is painting the entire decoration and this is why animations are
> supported.
> I opened also this one: https://phabricator.kde.org/T9899 in case any kwin
> developer can provide any feedback

Why the button size does not change on hoverEnter and hoverLeave ? 
m_animation->currentValue().toReal() inside BreezeEnhanced doesn't change when animations aren't supported ?

Or is there something prevents the button size being updated ?
Comment 26 Michail Vourlakos 2018-10-21 19:58:35 UTC
(In reply to trmdi from comment #25)
> (In reply to Michail Vourlakos from comment #19)
> > they are not relevant.
> > The kcm is painting the entire decoration and this is why animations are
> > supported.
> > I opened also this one: https://phabricator.kde.org/T9899 in case any kwin
> > developer can provide any feedback
> 
> Why the button size does not change on hoverEnter and hoverLeave ? 
> m_animation->currentValue().toReal() inside BreezeEnhanced doesn't change
> when animations aren't supported ?
> 
> Or is there something prevents the button size being updated ?

on plasmoid side this isnt possible because we cant know how much we must increase or not...

this should be taken care from the theme side. The theme should use the maximum size in order to draw everything, that means sierrabreeze could do the following:

e.g. if the provided size is 50px x 50px  it could use that 50px to draw the hover state and could use a portion of them eg. 35px to draw the normal state.

It is totally theme responsibility to draw properly its states
Comment 27 Michail Vourlakos 2018-10-25 11:07:29 UTC
an update: https://drive.google.com/file/d/16jUvWxFjt7GwWIF8LyM15NcPU0UQz2jH/view?usp=sharing

on purpose I am switching plugins(breeze and sierrabreeze) at every 6 hovers and
on purpose I am switching between different color schemes at every 3 hovers...

so this is totally feasible, including the color scheme change that Latte can provide per active window.

the buttons in the video are real AWC capable buttons that the user can use. 
1.Only thing is missing is the user to specify which theme prefers from the AWC settings
2. I dont quite like how the layout of AWC is produced. Is trying to do too many things e.g. buttons above the window title of menu etc...

I read somewhere that for [2] Zren is playing with it. 

Does anyone know who is responsible for AWC these days?
Comment 28 trmdi 2018-10-25 13:38:47 UTC
> Does anyone know who is responsible for AWC these days?

You, Zren, anyone else,... but not the original dev. He hasn't replied anyone on his github for a long time.
Comment 29 Chris Holland 2018-10-25 14:57:25 UTC
> 2. I dont quite like how the layout of AWC is produced. Is trying to do too many things e.g. buttons above the window title of menu etc...

> I read somewhere that for [2] Zren is playing with it. 

I've thought about changing the defaults to something more Ubuntu Unity like. There's now alternative widgets for displaying just the buttons + app title + global menu, so I believe this widget should focus on combining all 3 "widgets" by default in a manner similar to unity (which is probably what people are after).

https://phabricator.kde.org/D16328
Comment 30 Michail Vourlakos 2018-10-25 15:28:38 UTC
(In reply to Chris Holland from comment #29)
> > 2. I dont quite like how the layout of AWC is produced. Is trying to do too many things e.g. buttons above the window title of menu etc...
> 
> > I read somewhere that for [2] Zren is playing with it. 
> 
> I've thought about changing the defaults to something more Ubuntu Unity
> like. There's now alternative widgets for displaying just the buttons + app
> title + global menu
> 

Is there an alternative widget for displaying active window buttons that I don't know of?
Comment 31 trmdi 2018-10-25 16:32:27 UTC
Is there a Kwin dev who would suggest us a way to paint only a decoration button with animation created inside its class on a Plasmoid?
Comment 32 Michail Vourlakos 2018-10-27 12:33:30 UTC
and a real demonstration of this through AWC : https://www.youtube.com/watch?v=QkPv0-tfsXk

watch out the window buttons at the top right to update their color scheme properly
Comment 33 trmdi 2018-10-27 12:37:07 UTC
Nice. Are you about to release it?
Comment 34 Michail Vourlakos 2018-10-27 13:27:09 UTC
(In reply to trmdi from comment #33)
> Nice. Are you about to release it?

In the following steps:
1. make independent library for decoration buttons in order for any applet to be able to draw c++ window buttons correctly -done-
2. create an independent plasmoid that will use [1] in order to provide window buttons to the user in a simple way and support Latte new painting also. - working on it - 
3. Add some functionality from AWC directly to Latte. Double click to restore/maximize. Draw active window from panel. Scroll wheel at the panel changes desktop or activity.
4. Send patches to applets including AWC to support new Latte painting. If they are not accepted I will just provide Latte versions for them with that single commit.
Comment 35 trmdi 2018-10-27 14:16:01 UTC
(In reply to Michail Vourlakos from comment #34)
> 2. create an independent plasmoid that will use [1] in order to provide
> window buttons to the user in a simple way and support Latte new painting
> also. - working on it - 
> 3. Add some functionality from AWC directly to Latte. Double click to
> restore/maximize. Draw active window from panel. Scroll wheel at the panel
> changes desktop or activity.

2. It would be great if it can wrap the official global menu into it.
3. Do you think it's possible to support this feature ?https://github.com/kotelnik/plasma-applet-active-window-control/issues/30
Comment 36 Michail Vourlakos 2018-10-27 14:31:30 UTC
(In reply to trmdi from comment #35)
> (In reply to Michail Vourlakos from comment #34)

[2]. I dont think it is possible but it will be smart enough in order to hide/show itself accordingly. So it will be able to be next or before a global menu applet and the user should not notice any difference. It definitely wont be able to overlay a global menu applet.
[3]. I will need to play with it to check if the dragging can be canceled somehow, Zren has done fantastic research with it. If I have questions I will ask him
Comment 37 trmdi 2018-10-27 16:51:58 UTC
@psifidotos; 

A kwin dev has seen and answer your question in phabricator. You could discuss with him if you want.
Comment 38 Michail Vourlakos 2018-10-27 17:53:32 UTC
(In reply to trmdi from comment #35)
> (In reply to Michail Vourlakos from comment #34)
> 3. Do you think it's possible to support this feature
> ?https://github.com/kotelnik/plasma-applet-active-window-control/issues/30

I just did... ;)

I manage to orchestrate this with http://doc.qt.io/qt-5/qwindow.html#setMouseGrabEnabled

open a bug report in Latte please in order to track down when this will be landed in git version.
Comment 39 trmdi 2018-10-29 17:38:36 UTC
Can PreviewButton be directly derived from KDecoration2::DecorationButton and QQuickPaintedItem ? And for class PreviewButton: Using KDecoration2::paint() like this: https://stackoverflow.com/questions/42736889/c-multiple-inheritance-same-method-names-can-i-somehow-remove-one-of-them/42737015

Because I think, currently, when PreviewButton::paint() is called, it will be redirected to m_button->paint(). It's ok for draw the button.
https://github.com/KDE/kwin/blob/master/kcmkwin/kwindecoration/declarative-plugin/previewbutton.cpp#L135

But from BreezeEnhanced, when animation is running > opacity changes > update > BreezeEnhanced::paint() is called. But this time, it don't know about the *painter -> we don't see the animation.
https://github.com/tsujan/BreezeEnhanced/blob/master/breezebutton.h#L93


So, my idea is, we make PreviewButton derived directly from KDecoration2::Decorationbutton, so its paint method will be called directly (we do not have to redirect it to m_button->paint() anymore) > it knows about the *painter to repaint when opacity changes > we will see the animation.
Comment 40 Michail Vourlakos 2018-10-29 18:02:38 UTC
how will it be created? Currently Decoration creates them and returns them as DecorationButton
Comment 41 trmdi 2018-10-29 18:27:04 UTC
Isn't it created from QML file ? Because it is derived from QQuickPaintedItem. (we don't need m_button anymore)
Comment 42 Michail Vourlakos 2018-10-29 19:47:29 UTC
(In reply to trmdi from comment #41)
> Isn't it created from QML file ? Because it is derived from
> QQuickPaintedItem. (we don't need m_button anymore)

because I believe you wanna play with it... :) I rushed things a bit and uploaded it at: https://github.com/psifidotos/applet-window-buttons

it is just the first commits in order to start.
1. the libappletdecoration that is provided is independent from its kcm kwin decoration counterpart
2. I have assigned minimize|close in the main.qml code by hand
3. I am using breeze in the main.qml code

of course in the future all this will be able to assigned by preferences etc... but the c++ code of libappletdecoration I think it will help you also to test things by yourself.. ;)
Comment 43 Michail Vourlakos 2018-11-01 16:05:58 UTC
(In reply to trmdi from comment #41)
> Isn't it created from QML file ? Because it is derived from
> QQuickPaintedItem. (we don't need m_button anymore)

I FOUND IT!!!! :) and I AM VERY HAPPY!!! :)

this isnt a KDecoration issue!! This is Breeze faulty implementation and as such all its derivatives did not notice it!!!

you can read at: https://phabricator.kde.org/T9899 my findings!!!

With my applet afterwards animations work just fine!
Comment 44 trmdi 2018-11-01 16:27:53 UTC
Created attachment 116027 [details]
animation

OMG!!! I've just found that problem too, and was about to tell you about it.
Comment 45 Michail Vourlakos 2018-11-01 16:37:39 UTC
(In reply to trmdi from comment #44)
> Created attachment 116027 [details]
> animation
> 
> OMG!!! I've just found that problem too, and was about to tell you about it.

yep!! :) do you prefer to send the patches? I was thinking to send them later today.
Comment 46 trmdi 2018-11-01 16:43:46 UTC
(In reply to trmdi from comment #44)
> Created attachment 116027 [details]
> animation
> 
> OMG!!! I've just found that problem too, and was about to tell you about it.

(In reply to Michail Vourlakos from comment #45)
> (In reply to trmdi from comment #44)
> > Created attachment 116027 [details]
> > animation
> > 
> > OMG!!! I've just found that problem too, and was about to tell you about it.
> 
> yep!! :) do you prefer to send the patches? I was thinking to send them
> later today.

No, I've just learned C++ recently. I know almost nothing. You should do this.
Comment 47 Michail Vourlakos 2018-11-01 20:07:13 UTC
(In reply to trmdi from comment #46)
> (In reply to trmdi from comment #44)
> No, I've just learned C++ recently. I know almost nothing. You should do
> this.

no problem... sent and accepted...
https://phabricator.kde.org/D16596

someone should inform most of the breeze derivative creators in github in order to update their code based on https://phabricator.kde.org/D16596

can you do it please?
Comment 48 trmdi 2018-11-01 20:41:40 UTC
Sure!
Comment 49 trmdi 2018-11-06 05:50:02 UTC
Thanks everyone.
Now we have another wonderful applet for the requested feature:
http://psifidotos.blogspot.com/2018/11/window-buttons-applet-v01.html