Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions data/shaders/colorblindness-correction.vert
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,16 @@
uniform sampler2D tex;
uniform int COLORBLIND_MODE;
uniform float STRENGTH;
uniform bool PAUSE_FOR_SCREENSHOT;

void main() {
vec4 c = texture2D(tex, cogl_tex_coord0_in.xy);

if (PAUSE_FOR_SCREENSHOT) {
cogl_color_out = c;
return;
}

// RGB to LMS matrix
float L = (17.8824f * c.r) + (43.5161f * c.g) + (4.11935f * c.b);
float M = (3.45565f * c.r) + (27.1554f * c.g) + (3.86714f * c.b);
Expand Down
11 changes: 9 additions & 2 deletions data/shaders/monochrome.vert
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,16 @@

uniform sampler2D tex;
uniform float STRENGTH;
uniform bool PAUSE_FOR_SCREENSHOT;

void main() {
vec2 uv = cogl_tex_coord0_in.xy;
vec4 sample = texture2D (tex, uv);
vec4 sample = texture2D (tex, cogl_tex_coord0_in.xy);

if (PAUSE_FOR_SCREENSHOT) {
cogl_color_out = sample;
return;
}

vec3 luminance = vec3 (0.2126, 0.7512, 0.0722);
float gray = luminance.r * sample.r + luminance.g * sample.g + luminance.b * sample.b;
cogl_color_out = vec4 (
Expand Down
9 changes: 8 additions & 1 deletion src/ColorFilters/ColorblindnessCorrectionEffect.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,16 @@ public class Gala.ColorblindnessCorrectionEffect : Clutter.ShaderEffect {
get { return _strength; }
construct set {
_strength = value;

set_uniform_value ("STRENGTH", value);
queue_repaint ();
}
}
public bool pause_for_screenshot {
set {
set_uniform_value ("PAUSE_FOR_SCREENSHOT", (int) value);
queue_repaint ();
}
}

/*
* Used for fading in and out the effect, since you can't add transitions to effects.
Expand All @@ -47,5 +52,7 @@ public class Gala.ColorblindnessCorrectionEffect : Clutter.ShaderEffect {
} catch (Error e) {
critical ("Unable to load colorblindness-correction.vert: %s", e.message);
}

pause_for_screenshot = false;
}
}
22 changes: 14 additions & 8 deletions src/ColorFilters/FilterManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,25 @@ public class Gala.FilterManager : Object {
private const string TRANSITION_NAME = "strength-transition";
private const int TRANSITION_DURATION = 500;

private static FilterManager instance;
private static GLib.Settings settings;
public WindowManager wm { get; construct; }

public static void init (WindowManager wm) {
if (instance != null) {
return;
public bool pause_for_screenshot {
set {
foreach (unowned var _effect in wm.stage.get_effects ()) {
if (_effect is ColorblindnessCorrectionEffect) {
unowned var effect = (ColorblindnessCorrectionEffect) _effect;
effect.pause_for_screenshot = value;
} else if (_effect is MonochromeEffect) {
unowned var effect = (MonochromeEffect) _effect;
effect.pause_for_screenshot = value;
}
}
}

instance = new FilterManager (wm);
}

private FilterManager (WindowManager wm) {
private static GLib.Settings settings;

public FilterManager (WindowManager wm) {
Object (wm: wm);
}

Expand Down
9 changes: 8 additions & 1 deletion src/ColorFilters/MonochromeEffect.vala
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ public class Gala.MonochromeEffect : Clutter.ShaderEffect {
get { return _strength; }
construct set {
_strength = value;

set_uniform_value ("STRENGTH", value);
queue_repaint ();
}
}
public bool pause_for_screenshot {
set {
set_uniform_value ("PAUSE_FOR_SCREENSHOT", (int) value);
queue_repaint ();
}
}

/*
* Used for fading in and out the effect, since you can't add transitions to effects.
Expand All @@ -38,5 +43,7 @@ public class Gala.MonochromeEffect : Clutter.ShaderEffect {
} catch (Error e) {
critical ("Unable to load monochrome.vert: %s", e.message);
}

pause_for_screenshot = false;
}
}
14 changes: 12 additions & 2 deletions src/ScreenshotManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public class Gala.ScreenshotManager : Object {
public WindowManager wm { get; construct; }
[DBus (visible = false)]
public NotificationsManager notifications_manager { get; construct; }
[DBus (visible = false)]
public FilterManager filter_manager { get; construct; }

private bool? _is_redacted_font_available = null;
private bool is_redacted_font_available {
Expand Down Expand Up @@ -45,8 +47,8 @@ public class Gala.ScreenshotManager : Object {
private string prev_font_mono;
private uint conceal_timeout;

public ScreenshotManager (WindowManager wm, NotificationsManager notifications_manager) {
Object (wm: wm, notifications_manager: notifications_manager);
public ScreenshotManager (WindowManager wm, NotificationsManager notifications_manager, FilterManager filter_manager) {
Object (wm: wm, notifications_manager: notifications_manager, filter_manager: filter_manager);
}

construct {
Expand Down Expand Up @@ -266,8 +268,13 @@ public class Gala.ScreenshotManager : Object {
int width, height;
display.get_size (out width, out height);

filter_manager.pause_for_screenshot = true;

yield wait_stage_repaint ();

var image = take_screenshot (0, 0, width, height, include_cursor);
unconceal_text ();
filter_manager.pause_for_screenshot = false;

if (flash) {
flash_area (0, 0, width, height);
Expand All @@ -288,10 +295,13 @@ public class Gala.ScreenshotManager : Object {
public async void screenshot_area_with_cursor (int x, int y, int width, int height, bool include_cursor, bool flash, string filename, out bool success, out string filename_used) throws DBusError, IOError {
debug ("Taking area screenshot");

filter_manager.pause_for_screenshot = true;

yield wait_stage_repaint ();

var image = take_screenshot (x, y, width, height, include_cursor);
unconceal_text ();
filter_manager.pause_for_screenshot = false;

if (flash) {
flash_area (x, y, width, height);
Expand Down
14 changes: 8 additions & 6 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ namespace Gala {

public WindowTracker? window_tracker { get; private set; }

private FilterManager filter_manager;

private NotificationsManager notifications_manager;

private ScreenshotManager screenshot_manager;
Expand Down Expand Up @@ -133,6 +135,12 @@ namespace Gala {

AccessDialog.watch_portal ();


filter_manager = new FilterManager (this);
notifications_manager = new NotificationsManager ();
screenshot_manager = new ScreenshotManager (this, notifications_manager, filter_manager);
DBus.init (this, notifications_manager, screenshot_manager);

unowned Meta.Display display = get_display ();
display.gl_video_memory_purged.connect (() => {
Meta.Background.refresh_all ();
Expand Down Expand Up @@ -173,10 +181,6 @@ namespace Gala {
private void show_stage () {
unowned Meta.Display display = get_display ();

notifications_manager = new NotificationsManager ();
screenshot_manager = new ScreenshotManager (this, notifications_manager);
DBus.init (this, notifications_manager, screenshot_manager);

WindowListener.init (display);
keyboard_manager = new KeyboardManager (display);
window_tracker = new WindowTracker ();
Expand Down Expand Up @@ -301,8 +305,6 @@ namespace Gala {
// is set to NONE when we are in locked mode
screensaver.active_changed.connect (update_input_area);

FilterManager.init (this);

/*keybindings*/
var keybinding_settings = new GLib.Settings ("io.elementary.desktop.wm.keybindings");

Expand Down