diff --git a/lib/Utils.vala b/lib/Utils.vala index a66acb21..18ad1822 100644 --- a/lib/Utils.vala +++ b/lib/Utils.vala @@ -78,24 +78,29 @@ namespace Gala */ public class WindowIcon : GtkClutter.Texture { - public uint32 xid { get; construct; } - public int icon_size { get; construct; } - public Meta.Window window { get; construct; } + static Bamf.Matcher matcher; - static Bamf.Matcher? matcher = null; + static construct + { + matcher = Bamf.Matcher.get_default (); + } + + public Meta.Window window { get; construct; } + public int icon_size { get; construct; } bool loaded = false; + uint32 xid; public WindowIcon (Meta.Window window, int icon_size) { - var xid = (uint32)window.get_xwindow (); - Object (window: window, xid: xid, icon_size: icon_size); + Object (window: window, icon_size: icon_size); + } + construct + { width = icon_size; height = icon_size; - - if (matcher == null) - matcher = Bamf.Matcher.get_default (); + xid = (uint32) window.get_xwindow (); // new windows often reach mutter earlier than bamf, that's why // we have to wait until the next window opens and hope that it's diff --git a/src/InternalUtils.vala b/src/InternalUtils.vala index 339100dc..874a4e85 100644 --- a/src/InternalUtils.vala +++ b/src/InternalUtils.vala @@ -17,8 +17,6 @@ using Meta; -using Gala; - namespace Gala { public class InternalUtils @@ -36,11 +34,19 @@ namespace Gala { var actor = (WindowActor) window.get_compositor_private (); Object (window: window, source: actor); + } + construct + { if (source != null) window.unmanaged.connect (reset_source); } + ~SafeWindowClone () + { + window.unmanaged.disconnect (reset_source); + } + void reset_source () { // actually destroying the clone will be handled somewhere else, we just need @@ -48,11 +54,6 @@ namespace Gala // has been destroyed source = null; } - - ~SafeWindowClone () - { - window.unmanaged.disconnect (reset_source); - } } public static bool workspaces_only_on_primary () @@ -182,9 +183,9 @@ namespace Gala **/ // constants, mainly for natural expo - static const int GAPS = 10; - static const int MAX_TRANSLATIONS = 100000; - static const int ACCURACY = 20; + const int GAPS = 10; + const int MAX_TRANSLATIONS = 100000; + const int ACCURACY = 20; // some math utilities static int squared_distance (Gdk.Point a, Gdk.Point b) @@ -345,7 +346,8 @@ namespace Gala return result; } - /*public List natural_placement (Meta.Rectangle area, List windows) + /* TODO needs porting + public List natural_placement (Meta.Rectangle area, List windows) { Meta.Rectangle bounds = {area.x, area.y, area.width, area.height}; diff --git a/src/ShadowEffect.vala b/src/ShadowEffect.vala index a182c785..e029da90 100644 --- a/src/ShadowEffect.vala +++ b/src/ShadowEffect.vala @@ -36,6 +36,11 @@ namespace Gala // so we keep a cache to avoid creating the same texture all over again. static Gee.HashMap shadow_cache; + static construct + { + shadow_cache = new Gee.HashMap (); + } + public int shadow_size { get; construct; } public int shadow_spread { get; construct; } @@ -54,24 +59,20 @@ namespace Gala update_size (actor_width, actor_height); } - public void update_size (int actor_width, int actor_height) - { - var shadow = get_shadow (actor_width, actor_height, shadow_size, shadow_spread); - material.set_layer (0, shadow); - } - ~ShadowEffect () { if (current_key != null) decrement_shadow_users (current_key); } + public void update_size (int actor_width, int actor_height) + { + var shadow = get_shadow (actor_width, actor_height, shadow_size, shadow_spread); + material.set_layer (0, shadow); + } + Cogl.Texture get_shadow (int actor_width, int actor_height, int shadow_size, int shadow_spread) { - if (shadow_cache == null) { - shadow_cache = new Gee.HashMap (); - } - if (current_key != null) { decrement_shadow_users (current_key); }