Skip to content

Commit

Permalink
WindowClone/ActiveShape: Remove Gtk.StyleContext
Browse files Browse the repository at this point in the history
  • Loading branch information
leolost2605 committed Feb 24, 2024
1 parent 4223c89 commit ae554e7
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions src/Widgets/WindowClone.vala
Original file line number Diff line number Diff line change
Expand Up @@ -867,37 +867,18 @@ public class Gala.WindowClone : Clutter.Actor {
* Border to show around the selected window when using keyboard navigation.
*/
private class ActiveShape : CanvasActor {
private static int border_radius = -1;
private const int BORDER_RADIUS = 16;
private const double COLOR_OPACITY = 0.8;

construct {
notify["opacity"].connect (invalidate);
}

private void create_gtk_objects () {
var label_widget_path = new Gtk.WidgetPath ();
label_widget_path.append_type (typeof (Gtk.Label));

var style_context = new Gtk.StyleContext ();
style_context.add_class (Granite.STYLE_CLASS_CARD);
style_context.add_class (Granite.STYLE_CLASS_ROUNDED);
style_context.set_path (label_widget_path);

border_radius = style_context.get_property (
Gtk.STYLE_PROPERTY_BORDER_RADIUS,
Gtk.StateFlags.NORMAL
).get_int () * 4;
}

public void invalidate () {
content.invalidate ();
}

protected override void draw (Cairo.Context cr, int width, int height) {
if (border_radius == -1) {
create_gtk_objects ();
}

if (!visible || opacity == 0) {
return;
}
Expand All @@ -909,7 +890,7 @@ public class Gala.WindowClone : Clutter.Actor {
cr.paint ();
cr.restore ();

Drawing.Utilities.cairo_rounded_rectangle (cr, 0, 0, width, height, border_radius);
Drawing.Utilities.cairo_rounded_rectangle (cr, 0, 0, width, height, BORDER_RADIUS);
cr.set_source_rgba (color.red, color.green, color.blue, COLOR_OPACITY);
cr.fill ();
}
Expand Down

0 comments on commit ae554e7

Please sign in to comment.