-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[email protected]: Add Gaussian blur and color …
…blend options Version 2.0.0 1. Added a Gaussian blue effect (new default) which can produce a much more dramatic blur effect as compared to the simple blur effect produced by Clutter.BlurEffect 2. Added the ability to change the dimming overlay color which will produce a "color blending effect"
- Loading branch information
Showing
23 changed files
with
1,953 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
# Changelog | ||
|
||
## 2.0.0 | ||
|
||
Version 2 change only apply under Cinnamon 6 (Mint 21.3) or better | ||
|
||
* Added a Gaussian blur effect borrowed from Blur-My-Shell | ||
* Added an option to adjust the intensity of the Gaussian effect | ||
* Added ability to change the dimming color (Color blending) | ||
|
||
## 1.1.0 | ||
|
||
* Restored the ability to blur the overview background. It was removed in 2021 for no reason that I can discern | ||
* Added a config option to control if the blur effect is applied (defaults to on) | ||
* Changed the maintainer to myself since it currently has no maintainer | ||
* Added a README, CHANGELOG and version number | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,39 @@ | ||
# Blur Overview | ||
|
||
Allows you to Blur and adjust the dimming of the overview's background (window selection screen) | ||
Allows you to blur, colorize and adjust the dimming of the overview's background (window selection screen) | ||
|
||
## What is the Overview? | ||
|
||
The Overview shows you all the windows on the workspace and it can be activated in two ways: | ||
|
||
1. By using the "Show the window selection screen" hotkey. By default the hotkey is: Ctrl+Alt+Down. | ||
2. Moving the mouse pointer to the "Show all windows" Hot Corner. By default that is the top-left of the screen. | ||
|
||
## Requirements | ||
|
||
For the version 2.0.0 changes (Gaussian blur effect and color blending) you need to be running Cinnamon 6.0 or better (i.e Mint 21.3 or better). | ||
|
||
## Features | ||
|
||
Customize the Overview's background by: | ||
|
||
1. Adding a Simple or an adjustable intensity Gaussian blur effect. | ||
2. Adjust the dimming from 0 to 100%. | ||
3. Blend a color into the background to give it a custom hue. | ||
|
||
## Installation | ||
|
||
1. Right click on the cinnamon panel and click "System Settings" | ||
2. Click on the "Extensions" icon under the "Preferences" category | ||
3. Click the "Download" tab and then click the "Blur Overview" entry | ||
4. Click the "Install" button on the right and then return to the "Manage" tab | ||
6. Select the new "Blur Overview" entry and then click the "+" button at the bottom of the window | ||
7. Use the "gears" icon next to the "Blur Overview" entry to open the setting window and setup the preferred behaviour | ||
5. Select the new "Blur Overview" entry and then click the "+" button at the bottom of the window | ||
6. Use the "gears" icon next to the "Blur Overview" entry to open the setting window and setup the preferred behaviour | ||
|
||
## Feedback | ||
|
||
You can add a comment here and you can submit a feature request or a problem report here: [Spices Repo](https://github.com/linuxmint/cinnamon-spices-extensions/issues/new/choose) | ||
|
||
## Credits | ||
|
||
The Gaussian effect code was borrowed from the Gnome [Blur my shell](https://github.com/aunetx/blur-my-shell) extension by [Aurélien Hamy](https://github.com/aunetx). |
113 changes: 113 additions & 0 deletions
113
[email protected]/files/[email protected]/6.0/extension.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */ | ||
|
||
// Blur Overview: Blur background in overview. | ||
// Does not affect background dimming. | ||
|
||
// Copyright (C) 2012 Jen Bowen aka nailfarmer | ||
|
||
// This program is free software: you can redistribute it and/or m odify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
|
||
// This program is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
|
||
// You should have received a copy of the GNU General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
// Author: Jen Bowen aka nailfarmer | ||
// Fixes and changes by Kevin Langman 2024 | ||
// Gaussian Blur (borrowed from Blur-my-shell / Aurélien Hamy) modified for Cinnamon and added by Kevin Langman 2024 | ||
|
||
const Clutter = imports.gi.Clutter; | ||
const Tweener = imports.ui.tweener; | ||
const Overview = imports.ui.overview; | ||
const Settings = imports.ui.settings; | ||
|
||
const GaussianBlur = require("./gaussian_blur"); | ||
|
||
const ANIMATION_TIME = 0.25; | ||
|
||
let originalAnimate; | ||
|
||
let settings; | ||
|
||
const BlurType = { | ||
None: 0, | ||
Simple: 1, | ||
Gaussian: 2 | ||
} | ||
|
||
|
||
function _animateVisible() { | ||
if (this.visible || this.animationInProgress) | ||
return; | ||
|
||
this._oldAnimateVisible(); | ||
|
||
let children = this._background.get_children(); | ||
// Get the overview's background image and add the BlurEffect to it if configured to do so | ||
if (settings.blurType > BlurType.None) { | ||
let fx; | ||
let desktopBackground = children[0]; | ||
if (settings.blurType === BlurType.Simple) { | ||
fx = new Clutter.BlurEffect(); | ||
} else { | ||
fx = new GaussianBlur.GaussianBlurEffect({ | ||
radius: settings.radius, | ||
brightness: 1.0,//(100-settings.opacity)/100, | ||
width: 0, | ||
height: 0}); | ||
} | ||
desktopBackground.add_effect_with_name( "blur", fx ); | ||
} | ||
// Get the overview's backgroundShade child and set it's color to see-through solid black or the user specified color if "color blending" is enabled | ||
let backgroundShade = children[1]; | ||
let [ret,color] = Clutter.Color.from_string( (settings.colorBlend) ? settings.blendColor : "rgba(0,0,0,1)" ); | ||
backgroundShade.set_opacity(0); | ||
backgroundShade.set_background_color(color); | ||
|
||
// Dim the backgroundShade by making the black/"Color blend" color less see-through by the configured percentage | ||
Tweener.addTween( backgroundShade, | ||
{ opacity: Math.round(settings.opacity*2.55), | ||
time: ANIMATION_TIME, | ||
transition: 'easeNone' | ||
}); | ||
} | ||
|
||
function BlurSettings(uuid) { | ||
this._init(uuid); | ||
} | ||
|
||
BlurSettings.prototype = { | ||
_init: function(uuid) { | ||
this.settings = new Settings.ExtensionSettings(this, uuid); | ||
this.settings.bindProperty(Settings.BindingDirection.IN, 'opacity', 'opacity', null); | ||
this.settings.bindProperty(Settings.BindingDirection.IN, 'blurType', 'blurType', null); | ||
this.settings.bindProperty(Settings.BindingDirection.IN, 'radius', 'radius', null); | ||
this.settings.bindProperty(Settings.BindingDirection.IN, 'colorBlend', 'colorBlend', null); | ||
this.settings.bindProperty(Settings.BindingDirection.IN, 'blendColor', 'blendColor', null); | ||
} | ||
}; | ||
|
||
function init(extensionMeta) { | ||
settings = new BlurSettings(extensionMeta.uuid); | ||
|
||
originalAnimate = Overview.Overview.prototype._animateVisible; | ||
} | ||
|
||
function enable() { | ||
// Monkey patch the original animation | ||
Overview.Overview.prototype._animateVisible = this._animateVisible; | ||
Overview.Overview.prototype._oldAnimateVisible = originalAnimate; | ||
} | ||
|
||
function disable() { | ||
// Ideally, we should remove the tween off the background, | ||
// but I haven't found a way to make this work yet. Patches welcomed! | ||
delete Overview.Overview.prototype._oldAnimateVisible; | ||
Overview.Overview.prototype._animateVisible = originalAnimate; | ||
} |
70 changes: 70 additions & 0 deletions
70
...armer.nailfarmer.com/files/[email protected]/6.0/gaussian_blur.glsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
uniform sampler2D tex; | ||
uniform float sigma; | ||
uniform int dir; | ||
uniform float brightness; | ||
uniform float width; | ||
uniform float height; | ||
|
||
vec4 getTexture(vec2 uv) { | ||
if (uv.x < 3. / width) | ||
uv.x = 3. / width; | ||
|
||
if (uv.y < 3. / height) | ||
uv.y = 3. / height; | ||
|
||
if (uv.x > 1. - 3. / width) | ||
uv.x = 1. - 3. / width; | ||
|
||
if (uv.y > 1. - 3. / height) | ||
uv.y = 1. - 3. / height; | ||
|
||
return texture2D(tex, uv); | ||
} | ||
|
||
void main(void) { | ||
vec2 uv = cogl_tex_coord_in[0].xy; | ||
vec2 direction = vec2(dir, (1.0 - dir)); | ||
|
||
float pixel_step; | ||
if (dir == 0) | ||
pixel_step = 1.0 / height; | ||
else | ||
pixel_step = 1.0 / width; | ||
|
||
vec3 gauss_coefficient; | ||
gauss_coefficient.x = 1.0 / (sqrt(2.0 * 3.14159265) * sigma); | ||
gauss_coefficient.y = exp(-0.5 / (sigma * sigma)); | ||
gauss_coefficient.z = gauss_coefficient.y * gauss_coefficient.y; | ||
|
||
float gauss_coefficient_total = gauss_coefficient.x; | ||
|
||
vec4 ret = getTexture(uv) * gauss_coefficient.x; | ||
gauss_coefficient.xy *= gauss_coefficient.yz; | ||
|
||
int n_steps = int(ceil(1.5 * sigma)) * 2; | ||
|
||
for (int i = 1; i <= n_steps; i += 2) { | ||
float coefficient_subtotal = gauss_coefficient.x; | ||
gauss_coefficient.xy *= gauss_coefficient.yz; | ||
coefficient_subtotal += gauss_coefficient.x; | ||
|
||
float gauss_ratio = gauss_coefficient.x / coefficient_subtotal; | ||
|
||
float foffset = float(i) + gauss_ratio; | ||
vec2 offset = direction * foffset * pixel_step; | ||
|
||
ret += getTexture(uv + offset) * coefficient_subtotal; | ||
ret += getTexture(uv - offset) * coefficient_subtotal; | ||
|
||
gauss_coefficient_total += 2.0 * coefficient_subtotal; | ||
gauss_coefficient.xy *= gauss_coefficient.yz; | ||
} | ||
vec4 outColor = ret / gauss_coefficient_total; | ||
|
||
// apply brightness on the second pass (dir==0 comes last) | ||
if (dir == 0) { | ||
outColor.rgb *= brightness; | ||
} | ||
|
||
cogl_color_out = outColor; | ||
} |
Oops, something went wrong.