mirror of
https://github.com/elementary/gala.git
synced 2024-12-25 10:13:04 +03:00
Set accent color in DwellClick and PointerLocator (#909)
This commit is contained in:
parent
bba97d4654
commit
03fae35d74
@ -393,5 +393,26 @@ namespace Gala {
|
||||
public static int get_ui_scaling_factor () {
|
||||
return Meta.Backend.get_backend ().get_settings ().get_ui_scaling_factor ();
|
||||
}
|
||||
|
||||
private static Gtk.StyleContext selection_style_context = null;
|
||||
public static Gdk.RGBA get_theme_accent_color () {
|
||||
if (selection_style_context == null) {
|
||||
var dummy_label = new Gtk.Label ("");
|
||||
|
||||
unowned Gtk.StyleContext label_style_context = dummy_label.get_style_context ();
|
||||
|
||||
var widget_path = label_style_context.get_path ().copy ();
|
||||
widget_path.iter_set_object_name (-1, "selection");
|
||||
|
||||
selection_style_context = new Gtk.StyleContext ();
|
||||
selection_style_context.set_path (widget_path);
|
||||
selection_style_context.set_parent (label_style_context);
|
||||
}
|
||||
|
||||
return (Gdk.RGBA) selection_style_context.get_property (
|
||||
Gtk.STYLE_PROPERTY_BACKGROUND_COLOR,
|
||||
Gtk.StateFlags.NORMAL
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
|
||||
namespace Gala {
|
||||
public class DwellClickTimer : Clutter.Actor, Clutter.Animatable {
|
||||
private const string BACKGROUND_COLOR = "#64baff";
|
||||
private const double BACKGROUND_OPACITY = 0.7;
|
||||
private const uint BORDER_WIDTH_PX = 1;
|
||||
|
||||
@ -57,11 +56,6 @@ namespace Gala {
|
||||
queue_redraw ();
|
||||
});
|
||||
|
||||
var rgba = Gdk.RGBA ();
|
||||
rgba.parse (BACKGROUND_COLOR);
|
||||
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);
|
||||
|
||||
interface_settings = new GLib.Settings ("org.gnome.desktop.interface");
|
||||
scaling_factor = InternalUtils.get_ui_scaling_factor ();
|
||||
|
||||
@ -100,6 +94,12 @@ namespace Gala {
|
||||
}
|
||||
|
||||
public override void paint (Clutter.PaintContext context) {
|
||||
var rgba = InternalUtils.get_theme_accent_color ();
|
||||
|
||||
/* 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);
|
||||
|
||||
var radius = int.min (cursor_size / 2, cursor_size / 2);
|
||||
var end_angle = START_ANGLE + angle;
|
||||
|
||||
|
@ -21,9 +21,8 @@ namespace Gala {
|
||||
private const int HEIGHT_PX = 300;
|
||||
private const int ANIMATION_TIME_MS = 300;
|
||||
|
||||
private const uint BORDER_WIDTH_PX = 3;
|
||||
private const uint BORDER_WIDTH_PX = 1;
|
||||
|
||||
private const string BACKGROUND_COLOR = "#64baff";
|
||||
private const double BACKGROUND_OPACITY = 0.7;
|
||||
|
||||
public weak WindowManager wm { get; construct; }
|
||||
@ -54,11 +53,6 @@ namespace Gala {
|
||||
update_surface ();
|
||||
set_size (WIDTH_PX * scaling_factor, HEIGHT_PX * scaling_factor);
|
||||
|
||||
var rgba = Gdk.RGBA ();
|
||||
rgba.parse (BACKGROUND_COLOR);
|
||||
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);
|
||||
|
||||
Meta.MonitorManager.@get ().monitors_changed.connect (update_surface);
|
||||
}
|
||||
|
||||
@ -120,6 +114,12 @@ namespace Gala {
|
||||
return;
|
||||
}
|
||||
|
||||
var rgba = InternalUtils.get_theme_accent_color ();
|
||||
|
||||
/* 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);
|
||||
|
||||
if (timeout_id != 0) {
|
||||
GLib.Source.remove (timeout_id);
|
||||
timeout_id = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user