diff --git a/lib/uh/wm/client.rb b/lib/uh/wm/client.rb index a5c57fc..90828b2 100644 --- a/lib/uh/wm/client.rb +++ b/lib/uh/wm/client.rb @@ -48,6 +48,12 @@ module Uh @unmap_count += 1 self end + + def focus + @window.raise + @window.focus + self + end end end end diff --git a/spec/uh/wm/client_spec.rb b/spec/uh/wm/client_spec.rb index 482d385..0904c88 100644 --- a/spec/uh/wm/client_spec.rb +++ b/spec/uh/wm/client_spec.rb @@ -101,6 +101,22 @@ module Uh expect(client.hide).to be client end end + + describe '#focus' do + it 'raises the window' do + expect(window).to receive :raise + client.focus + end + + it 'focuses the window' do + expect(window).to receive :focus + client.focus + end + + it 'returns self' do + expect(client.focus).to be client + end + end end end end