From 38a90ab0af4e3f85e7a2b78b3c696e6c06f05ca8 Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Mon, 20 Apr 2015 10:18:39 +0000 Subject: [PATCH] Register for layout unmanage handling in runner --- lib/uh/wm/runner.rb | 4 ++++ spec/uh/wm/runner_spec.rb | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/lib/uh/wm/runner.rb b/lib/uh/wm/runner.rb index 22625a7..6e6aab3 100644 --- a/lib/uh/wm/runner.rb +++ b/lib/uh/wm/runner.rb @@ -115,6 +115,10 @@ module Uh log "Managing client #{client}" layout << client end + @events.on :unmanage do |client| + log "Unmanaging client #{client}" + layout.remove client + end end def register_keybinds_hooks diff --git a/spec/uh/wm/runner_spec.rb b/spec/uh/wm/runner_spec.rb index 88a259f..f91c81f 100644 --- a/spec/uh/wm/runner_spec.rb +++ b/spec/uh/wm/runner_spec.rb @@ -2,6 +2,7 @@ SomeLayout = Class.new do define_method(:register) { |*args| } define_method(:suggest_geo) { Uh::Geo.new(0, 0, 42, 42) } define_method(:<<) { |*args| } + define_method(:remove) { |*args| } end module Uh @@ -93,6 +94,12 @@ module Uh expect(env.layout).to receive(:<<).with :client runner.events.emit :manage, args: :client end + + it 'registers for :unmanage event' do + runner.register_event_hooks + expect(env.layout).to receive(:remove).with :client + runner.events.emit :unmanage, args: :client + end end context 'keys hooks' do