[WIP] Sync titlebar button appearance with GTK CSD apps
AbandonedPublic

Authored by gikari on Apr 6 2020, 2:13 PM.

Details

Reviewers
cblack
Group Reviewers
Breeze
Plasma
Summary

Currently GTK applications with Client Side Decoration always use
decorations from the respected GTK CSS theme. Because of CSS nature
different themes may handle decorations in the headerbars differently,
therefore making modifying them via user css a very hard task. However,
what we can do is to use decoration appearance syncing in our own theme - Breeze GTK.

Breeze GTK uses images (.svg and .png) for representing decoration
buttons (close, minimize, maximize) appearance. So to achieve the goal
what we can do (hypothetically) is the following:

  1. Ask KWin to render current decoration buttons to custom QPainters. For each button we must export every state (clicked, hovered, normal).
  2. QPainters then export decoration buttons to pixmaps or/and svg.
  3. Then we will save those images to assets folder in ~/.config/gtk-3.0/assets or something like that.
  4. Then we will create custom .css for Breeze GTK, that tells the theme to use these saved images for decorations.

To do:

  • Correctly crop svg files or render all decorations with the fixed size
  • Support Aurorae themes
  • Find a way to write correct CSS for decorations
  • Generate checked maximized state

Depends on D29509

Test Plan

Currently it is in a proof of concept state.

  • Apply D29509
  • Restart kded5
  • Check if decoration images are generated in ~/.config/gtk-3.0/assets folder

Diff Detail

Repository
R99 KDE Gtk Configuration Tool
Branch
decorations-appearance (branched from master)
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 26611
Build 26629: arc lint + arc unit
gikari created this revision.Apr 6 2020, 2:13 PM
Restricted Application added a project: Plasma. · View Herald TranscriptApr 6 2020, 2:13 PM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
gikari requested review of this revision.Apr 6 2020, 2:13 PM
gikari edited the summary of this revision. (Show Details)Apr 6 2020, 2:14 PM
gikari updated this revision to Diff 79488.Apr 6 2020, 2:34 PM
  • Add missed Licence header
  • Remove unnecessary CMake commands
gikari updated this revision to Diff 82124.Wed, May 6, 5:39 PM
  • Export decorations as png images

Global things to do:

  • Export decorations in 3 different states: normal, clicked and hovered
  • Consider exporting in SVG
  • Write CSS into custom gtk css file
gikari edited the summary of this revision. (Show Details)Wed, May 6, 5:41 PM
gikari edited the test plan for this revision. (Show Details)
gikari updated this revision to Diff 82143.Wed, May 6, 7:13 PM
gikari edited the summary of this revision. (Show Details)
gikari edited the test plan for this revision. (Show Details)
  • Use unique_ptr for buttons
  • Propagate events to buttons

Things to do:

  • Figure out why does this only work with some decorations (hello and sierra breeze enchanced) and for some does not (breeze, plastic, particially oxygen)
  • Properly scale images into Pixmap
  • Consider exporting in SVG
  • Write CSS into custom gtk css file
gikari updated this revision to Diff 82167.Wed, May 6, 9:44 PM
  • Make buttons work with Breeze theme by respecting pallete.
gikari updated this revision to Diff 82206.Thu, May 7, 2:27 PM
  • Render buttons to SVGs
gikari edited the summary of this revision. (Show Details)Thu, May 7, 2:30 PM
gikari edited the test plan for this revision. (Show Details)Thu, May 7, 2:46 PM
gikari edited the summary of this revision. (Show Details)
ngraham edited the summary of this revision. (Show Details)Thu, May 7, 4:11 PM
gikari updated this revision to Diff 82266.Fri, May 8, 2:08 PM

Support the maximize button in the checked state

gikari edited the summary of this revision. (Show Details)Fri, May 8, 2:08 PM
ngraham added a subscriber: ngraham.Fri, May 8, 4:28 PM

Very cool stuff!

cblack added a comment.Fri, May 8, 4:50 PM

While this is neat, I'm fairly sure that creating the CSS for this in a manner that works across themes is going to be hard if not impossible. Even our own Breeze GTK uses palette swaps rather than unique pixmaps for every state.

gikari updated this revision to Diff 82294.Fri, May 8, 5:03 PM

Export buttons with fixed geometry (Now all buttons are exported with the same size)

gikari edited the summary of this revision. (Show Details)Fri, May 8, 5:04 PM
gikari added a comment.EditedFri, May 8, 5:25 PM

While this is neat, I'm fairly sure that creating the CSS for this in a manner that works across themes is going to be hard if not impossible.

I'm not completely sure about this right now, but currently I only think of supporting our own GTK theme - Breeze-GTK.

Even our own Breeze GTK uses palette swaps rather than unique pixmaps for every state.

I got it working somehow on Breeze Gtk:

However I'm not sure how to provide CSS, that I'm using now. It's rather big to hardcore IMO. Should I use Sass and install generated file in ~/.config/gtk-3.0/windowdecorations.css, so I could just enable/disable it with include statement?

gikari updated this revision to Diff 82365.Sat, May 9, 12:49 PM
  • Add support for aurorae themes
  • Plastic does not work, but in that case decoration buttons in GTK apps are Breeze
gikari edited the summary of this revision. (Show Details)Sat, May 9, 12:50 PM
trmdi added a subscriber: trmdi.Sat, May 9, 12:53 PM

Just a question, SierraBreezeEnhanced has a feature called "Unison hovering". Does this support it?

Just a question, SierraBreezeEnhanced has a feature called "Unison hovering". Does this support it?

No. That's because it is the GTK, who is responsible for hovering behavior. I only change the appearance of the buttons. Behavior stays the same.

gikari added a comment.Sat, May 9, 1:05 PM

Just a question, SierraBreezeEnhanced has a feature called "Unison hovering". Does this support it?

Also, I think, that to support that you actually need to do a lot of upstream changes.

  1. Provide unison hovering API for KDecoration (i.e. option must exist for all decorations)
  2. Provide unison hovering API for GTK, so that there will be a config option in gsettings to turn on/off unison hovering.
  3. Once the above is done it is actually possible to implement syncing. But I doubt that the above patches will be accepted.