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
23 changes: 10 additions & 13 deletions lib/Drawing/StyleManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,19 @@ public class Gala.Drawing.StyleManager : Object {

private const string FDO_ACCOUNTS_NAME = "org.freedesktop.Accounts";
private const string FDO_ACCOUNTS_PATH = "/org/freedesktop/Accounts";

private const float ACCENT_COLOR_ALPHA = 0.25f;
private const Gdk.RGBA DEFAULT_ACCENT_COLOR = { 0, 0, 0, ACCENT_COLOR_ALPHA };
private const uint8 ACCENT_COLOR_ALPHA = 64;

private static GLib.Once<StyleManager> instance;
public static StyleManager get_instance () {
return instance.once (() => new StyleManager ());
}

public ColorScheme prefers_color_scheme { get; private set; default = LIGHT; }
public Gdk.RGBA theme_accent_color { get; private set; default = DEFAULT_ACCENT_COLOR; }
#if !HAS_MUTTER47
public Clutter.Color theme_accent_color { get; private set; default = { 0, 0, 0, ACCENT_COLOR_ALPHA }; }
#else
public Cogl.Color theme_accent_color { get; private set; default = { 0, 0, 0, ACCENT_COLOR_ALPHA }; }
#endif

private PantheonAccountsService? pantheon_proxy;
private SettingsDaemonAccountsService? settings_daemon_proxy;
Expand Down Expand Up @@ -94,16 +96,11 @@ public class Gala.Drawing.StyleManager : Object {
private void update_color (int color) {
var rgb = get_color (color);

var r = ((rgb >> 16) & 255) / 255.0f;
var g = ((rgb >> 8) & 255) / 255.0f;
var b = (rgb & 255) / 255.0f;
var r = (uint8) ((rgb >> 16) & 255);
var g = (uint8) ((rgb >> 8) & 255);
var b = (uint8) (rgb & 255);

theme_accent_color = {
r,
g,
b,
ACCENT_COLOR_ALPHA
};
theme_accent_color = { r, g, b, ACCENT_COLOR_ALPHA };
}

private int get_color (int color) {
Expand Down
6 changes: 3 additions & 3 deletions src/Widgets/DwellClickTimer.vala
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ public class Gala.DwellClickTimer : Clutter.Actor, Clutter.Animatable {
}

var rgba = Drawing.StyleManager.get_instance ().theme_accent_color;

var red = rgba.red / 255.0, green = rgba.green / 255.0, blue = rgba.blue / 255.0;
stroke_color = new Cairo.Pattern.rgb (red, green, blue);
/* Don't use alpha from the stylesheet to ensure contrast */
stroke_color = new Cairo.Pattern.rgb (rgba.red, rgba.green, rgba.blue);
fill_color = new Cairo.Pattern.rgba (rgba.red, rgba.green, rgba.blue, BACKGROUND_OPACITY);
fill_color = new Cairo.Pattern.rgba (red, green, blue, BACKGROUND_OPACITY);

var radius = int.min (cursor_size / 2, cursor_size / 2);
var end_angle = START_ANGLE + angle;
Expand Down
8 changes: 1 addition & 7 deletions src/Widgets/MultitaskingView/WindowClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -629,13 +629,7 @@ public class Gala.WindowClone : ActorTarget, RootTarget {
}

public void update_color () {
var accent_color = Drawing.StyleManager.get_instance ().theme_accent_color;
background_color = {
(uint8) (accent_color.red * uint8.MAX),
(uint8) (accent_color.green * uint8.MAX),
(uint8) (accent_color.blue * uint8.MAX),
(uint8) (COLOR_OPACITY * uint8.MAX)
};
background_color = Drawing.StyleManager.get_instance ().theme_accent_color;
}
}
}
6 changes: 3 additions & 3 deletions src/Widgets/PointerLocator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ public class Gala.PointerLocator : Clutter.Actor, Clutter.Animatable {
add_transition ("circle", transition);

var rgba = Drawing.StyleManager.get_instance ().theme_accent_color;

var red = rgba.red / 255.0, green = rgba.green / 255.0, blue = rgba.blue / 255.0;
stroke_color = new Cairo.Pattern.rgb (red, green, blue);
/* Don't use alpha from the stylesheet to ensure contrast */
stroke_color = new Cairo.Pattern.rgb (rgba.red, rgba.green, rgba.blue);
fill_color = new Cairo.Pattern.rgba (rgba.red, rgba.green, rgba.blue, BACKGROUND_OPACITY);
fill_color = new Cairo.Pattern.rgba (red, green, blue, BACKGROUND_OPACITY);

#if HAS_MUTTER48
unowned var tracker = display.get_compositor ().get_backend ().get_cursor_tracker ();
Expand Down
14 changes: 2 additions & 12 deletions src/Widgets/WindowSwitcher/WindowSwitcherIcon.vala
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,9 @@ public class Gala.WindowSwitcherIcon : Clutter.Actor {
public bool selected {
set {
if (value) {
var accent_color = Drawing.StyleManager.get_instance ().theme_accent_color;
background_color = {
(uint8) (accent_color.red * uint8.MAX),
(uint8) (accent_color.green * uint8.MAX),
(uint8) (accent_color.blue * uint8.MAX),
(uint8) (accent_color.alpha * uint8.MAX)
};
background_color = Drawing.StyleManager.get_instance ().theme_accent_color;
} else {
#if HAS_MUTTER47
background_color = Cogl.Color.from_4f (0, 0, 0, 0);
#else
background_color = Clutter.Color.alloc ();
#endif
background_color = { 0, 0, 0, 0 };
}

get_accessible ().notify_state_change (Atk.StateType.SELECTED, value);
Expand Down
13 changes: 4 additions & 9 deletions src/WindowManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -949,18 +949,13 @@ namespace Gala {

public override void show_tile_preview (Meta.Window window, Mtk.Rectangle tile_rect, int tile_monitor_number) {
if (tile_preview == null) {
tile_preview = new Clutter.Actor ();
var rgba = Drawing.StyleManager.get_instance ().theme_accent_color;
tile_preview.background_color = {
(uint8)(255.0 * rgba.red),
(uint8)(255.0 * rgba.green),
(uint8)(255.0 * rgba.blue),
(uint8)(255.0 * rgba.alpha)
tile_preview = new Clutter.Actor () {
background_color = Drawing.StyleManager.get_instance ().theme_accent_color,
opacity = 0
};
tile_preview.opacity = 0U;

window_group.add_child (tile_preview);
} else if (tile_preview.is_visible ()) {
} else {
float width, height, x, y;
tile_preview.get_position (out x, out y);
tile_preview.get_size (out width, out height);
Expand Down