mirror of
https://github.com/elementary/gala.git
synced 2024-09-11 15:15:39 +03:00
Add setting for greyscale
This commit is contained in:
parent
50694796d4
commit
bd347ef9ef
@ -155,6 +155,10 @@
|
|||||||
<summary>Attach modal dialogs</summary>
|
<summary>Attach modal dialogs</summary>
|
||||||
<description>When true, instead of having independent titlebars, modal dialogs appear attached to the titlebar of the parent window and are moved together with the parent window.</description>
|
<description>When true, instead of having independent titlebars, modal dialogs appear attached to the titlebar of the parent window and are moved together with the parent window.</description>
|
||||||
</key>
|
</key>
|
||||||
|
<key type="b" name="greyscale">
|
||||||
|
<default>false</default>
|
||||||
|
<summary>If the display should be greyscale</summary>
|
||||||
|
</key>
|
||||||
<key type="s" name="button-layout">
|
<key type="s" name="button-layout">
|
||||||
<default>'close:maximize'</default>
|
<default>'close:maximize'</default>
|
||||||
<summary>Arrangement of buttons on the titlebar</summary>
|
<summary>Arrangement of buttons on the titlebar</summary>
|
||||||
|
@ -74,6 +74,7 @@ namespace Gala
|
|||||||
public bool attach_modal_dialogs { get; set; }
|
public bool attach_modal_dialogs { get; set; }
|
||||||
public bool dim_parents { get; set; }
|
public bool dim_parents { get; set; }
|
||||||
public string workspace_switcher_background { get; set; }
|
public string workspace_switcher_background { get; set; }
|
||||||
|
public bool greyscale { get; set; }
|
||||||
|
|
||||||
static AppearanceSettings? instance = null;
|
static AppearanceSettings? instance = null;
|
||||||
|
|
||||||
|
@ -70,7 +70,9 @@ namespace Gala
|
|||||||
Clutter.Actor? last_hotcorner;
|
Clutter.Actor? last_hotcorner;
|
||||||
ScreenSaver? screensaver;
|
ScreenSaver? screensaver;
|
||||||
|
|
||||||
Clutter.Actor? tile_preview;
|
Clutter.Actor? tile_preview;
|
||||||
|
|
||||||
|
Clutter.ShaderEffect? greyscale_effect;
|
||||||
|
|
||||||
Window? moving; //place for the window that is being moved over
|
Window? moving; //place for the window that is being moved over
|
||||||
|
|
||||||
@ -310,7 +312,9 @@ namespace Gala
|
|||||||
|
|
||||||
update_input_area ();
|
update_input_area ();
|
||||||
|
|
||||||
stage.show ();
|
stage.show ();
|
||||||
|
toggle_greyscale ();
|
||||||
|
AppearanceSettings.get_default ().notify["greyscale"].connect (toggle_greyscale);
|
||||||
|
|
||||||
// let the session manager move to the next phase
|
// let the session manager move to the next phase
|
||||||
Meta.register_with_session ();
|
Meta.register_with_session ();
|
||||||
@ -323,6 +327,33 @@ namespace Gala
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void toggle_greyscale ()
|
||||||
|
{
|
||||||
|
if (greyscale_effect == null) {
|
||||||
|
greyscale_effect = new Clutter.ShaderEffect (Clutter.ShaderType.FRAGMENT_SHADER);
|
||||||
|
greyscale_effect.set_name ("greyscale");
|
||||||
|
greyscale_effect.set_shader_source ("""
|
||||||
|
uniform sampler2D texture;
|
||||||
|
void main () {
|
||||||
|
vec4 color = texture2D (texture, cogl_tex_coord0_in.xy);
|
||||||
|
float gray = dot(color.rgb, vec3(0.299, 0.587, 0.114));
|
||||||
|
cogl_color_out = vec4(vec3(gray), 1.0);
|
||||||
|
}
|
||||||
|
""");
|
||||||
|
greyscale_effect.set_uniform_value ("texture", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AppearanceSettings.get_default ().greyscale) {
|
||||||
|
if (ui_group.get_effect ("greyscale") == null) {
|
||||||
|
ui_group.add_effect (greyscale_effect);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (ui_group.get_effect ("greyscale") != null) {
|
||||||
|
ui_group.remove_effect (greyscale_effect);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void configure_hotcorners ()
|
void configure_hotcorners ()
|
||||||
{
|
{
|
||||||
var geometry = get_screen ().get_monitor_geometry (get_screen ().get_primary_monitor ());
|
var geometry = get_screen ().get_monitor_geometry (get_screen ().get_primary_monitor ());
|
||||||
|
Loading…
Reference in New Issue
Block a user