highlight active window with dominant color

This commit is contained in:
Jordan Ribera
2019-05-02 21:21:13 -07:00
parent ed0fd0a5de
commit a1e11e1ff7
4 changed files with 65 additions and 8 deletions

View File

@@ -839,13 +839,13 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="row_spacing">4</property>
<property name="row_spacing">8</property>
<child>
<object class="GtkLabel" id="focus_highlight_color_label">
<object class="GtkLabel" id="focus_highlight_dominant_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Highlight color</property>
<property name="label" translatable="yes">Icon dominant color</property>
<property name="xalign">0</property>
</object>
<packing>
@@ -853,6 +853,31 @@
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="focus_highlight_dominant_switch">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">end</property>
<property name="valign">center</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="focus_highlight_color_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Custom color</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkColorButton" id="focus_highlight_color_colorbutton">
<property name="visible">True</property>
@@ -862,7 +887,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
@@ -875,7 +900,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
@@ -889,7 +914,7 @@
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
</object>

View File

@@ -214,6 +214,7 @@ var taskbarAppIcon = Utils.defineClass({
this._dtpSettings.connect('changed::dot-color-unfocused-3', Lang.bind(this, this._settingsChangeRefresh)),
this._dtpSettings.connect('changed::dot-color-unfocused-4', Lang.bind(this, this._settingsChangeRefresh)),
this._dtpSettings.connect('changed::focus-highlight', Lang.bind(this, this._settingsChangeRefresh)),
this._dtpSettings.connect('changed::focus-highlight-dominant', Lang.bind(this, this._settingsChangeRefresh)),
this._dtpSettings.connect('changed::focus-highlight-color', Lang.bind(this, this._settingsChangeRefresh)),
this._dtpSettings.connect('changed::focus-highlight-opacity', Lang.bind(this, this._settingsChangeRefresh)),
this._dtpSettings.connect('changed::group-apps-label-font-size', Lang.bind(this, this._updateWindowTitleStyle)),
@@ -510,8 +511,8 @@ var taskbarAppIcon = Utils.defineClass({
}
}
inlineStyle += "background-color: " + cssHexTocssRgba(this._dtpSettings.get_string('focus-highlight-color'),
this._dtpSettings.get_int('focus-highlight-opacity') * 0.01);
let highlightColor = this._getFocusHighlightColor();
inlineStyle += "background-color: " + cssHexTocssRgba(highlightColor, this._dtpSettings.get_int('focus-highlight-opacity') * 0.01);
}
if(this._dotsContainer.get_style() != inlineStyle) {
@@ -957,6 +958,15 @@ var taskbarAppIcon = Utils.defineClass({
return color;
},
_getFocusHighlightColor: function() {
if (this._dtpSettings.get_boolean('focus-highlight-dominant')) {
let dce = new Utils.DominantColorExtractor(this.app);
let palette = dce._getColorPalette();
if (palette) return palette.original;
}
return this._dtpSettings.get_string('focus-highlight-color');
},
_drawRunningIndicator: function(area, type, isFocused) {
let n = this._getRunningIndicatorCount();

View File

@@ -377,6 +377,22 @@ const Settings = new Lang.Class({
'sensitive',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('focus-highlight-dominant',
this._builder.get_object('focus_highlight_dominant_switch'),
'active',
Gio.SettingsBindFlags.DEFAULT);
this._settings.bind('focus-highlight-dominant',
this._builder.get_object('focus_highlight_color_label'),
'sensitive',
Gio.SettingsBindFlags.INVERT_BOOLEAN);
this._settings.bind('focus-highlight-dominant',
this._builder.get_object('focus_highlight_color_colorbutton'),
'sensitive',
Gio.SettingsBindFlags.INVERT_BOOLEAN);
(function() {
let rgba = new Gdk.RGBA();
rgba.parse(this._settings.get_string('focus-highlight-color'));
@@ -424,6 +440,7 @@ const Settings = new Lang.Class({
this._builder.get_object('dot_size_spinbutton').set_value(this._settings.get_int('dot-size'));
this._settings.set_value('focus-highlight', this._settings.get_default_value('focus-highlight'));
this._settings.set_value('focus-highlight-dominant', this._settings.get_default_value('focus-highlight-dominant'));
} else {
// remove the settings box so it doesn't get destroyed;

View File

@@ -155,6 +155,11 @@
<summary>Highlight icon of focused application</summary>
<description>Whether to highlight the background of the currently focused application's icon</description>
</key>
<key type="b" name="focus-highlight-dominant">
<default>false</default>
<summary>Highlight icon dominant color</summary>
<description>Base the active window highlight color on that application's icon</description>
</key>
<key type="s" name="focus-highlight-color">
<default>"#EEEEEE"</default>
<summary>Color of highlight of focused application</summary>