From 195dfd06f9e5ac856179882b717ee96bd38a2b4f Mon Sep 17 00:00:00 2001 From: Rico Tzschichholz Date: Sun, 22 Jun 2014 23:44:07 +0200 Subject: [PATCH] Avoid using lambdas to disconnect properly --- .../MultitaskingView/WorkspaceClone.vala | 38 ++++++++++++------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/src/Widgets/MultitaskingView/WorkspaceClone.vala b/src/Widgets/MultitaskingView/WorkspaceClone.vala index 392874d6..d40a4067 100644 --- a/src/Widgets/MultitaskingView/WorkspaceClone.vala +++ b/src/Widgets/MultitaskingView/WorkspaceClone.vala @@ -86,7 +86,7 @@ namespace Gala { opened = false; - var screen = workspace.get_screen (); + unowned Screen screen = workspace.get_screen (); var monitor_geometry = screen.get_monitor_geometry (screen.get_primary_monitor ()); background = new FramedBackground (workspace.get_screen ()); @@ -130,16 +130,10 @@ namespace Gala } }); - screen.window_left_monitor.connect ((monitor, window) => { - if (monitor == screen.get_primary_monitor ()) - remove_window (window); - }); - workspace.window_removed.connect (remove_window); - - screen.window_entered_monitor.connect ((monitor, window) => { - add_window (window); - }); + screen.window_entered_monitor.connect (window_entered_monitor); + screen.window_left_monitor.connect (window_left_monitor); workspace.window_added.connect (add_window); + workspace.window_removed.connect (remove_window); add_child (background); add_child (window_container); @@ -157,10 +151,17 @@ namespace Gala ~WorkspaceClone () { + unowned Screen screen = workspace.get_screen (); + + screen.window_entered_monitor.disconnect (window_entered_monitor); + screen.window_left_monitor.disconnect (window_left_monitor); + workspace.window_added.disconnect (add_window); + workspace.window_removed.disconnect (remove_window); + background.destroy (); } - private void add_window (Window window) + void add_window (Window window) { if (window.window_type != WindowType.NORMAL || window.get_workspace () != workspace @@ -175,13 +176,24 @@ namespace Gala icon_group.add_window (window); } - private void remove_window (Window window) + void remove_window (Window window) { window_container.remove_window (window); icon_group.remove_window (window, opened); } - private void shrink_rectangle (ref Meta.Rectangle rect, int amount) + void window_entered_monitor (Screen screen, int monitor, Window window) + { + add_window (window); + } + + void window_left_monitor (Screen screen, int monitor, Window window) + { + if (monitor == screen.get_primary_monitor ()) + remove_window (window); + } + + static inline void shrink_rectangle (ref Meta.Rectangle rect, int amount) { rect.x += amount; rect.y += amount;