From 1cc1f98ad2afc14c7b346df36285bbf00f52e483 Mon Sep 17 00:00:00 2001 From: Thibault Jouan Date: Wed, 29 Apr 2015 02:38:30 +0000 Subject: [PATCH] Implement `kill' action keyword When invoked, will kill the client returned by `layout.current_client`. ICCCM WM_DELETE_WINDOW is used instead if the window reports to support this protocol. --- features/actions/kill.feature | 11 +++++++++++ features/steps/x_steps.rb | 11 +++++++++++ lib/uh/wm/actions_handler.rb | 4 ++++ spec/uh/wm/actions_handler_spec.rb | 15 +++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 features/actions/kill.feature diff --git a/features/actions/kill.feature b/features/actions/kill.feature new file mode 100644 index 0000000..e9031a0 --- /dev/null +++ b/features/actions/kill.feature @@ -0,0 +1,11 @@ +Feature: `kill' action keyword + + @icccm_window + Scenario: kills current client + Given uhwm is running with this run control file: + """ + key(:f) { kill_current } + """ + And an ICCCM compliant window is mapped + When I press the alt+f keys + Then the ICCCM window must be unmapped by the manager diff --git a/features/steps/x_steps.rb b/features/steps/x_steps.rb index d145146..3ac42aa 100644 --- a/features/steps/x_steps.rb +++ b/features/steps/x_steps.rb @@ -1,3 +1,10 @@ +Given /^an ICCCM compliant window is mapped$/ do + icccm_window_start + timeout_until 'window not mapped after %d seconds' do + x_window_map_state(icccm_window_name) == 'IsViewable' + end +end + Given /^a(?:\s(\w+))? window is mapped$/ do |ident| x_client(ident).map.sync timeout_until 'window not mapped after %d seconds' do @@ -42,6 +49,10 @@ Then /^the(?:\s(\w+))? window must be mapped$/ do |ident| end end +Then /^the ICCCM window must be unmapped by the manager$/ do + uhwm_wait_output /unmanag.+#{icccm_window_name}/i +end + Then /^the window must be focused$/ do timeout_until 'window not focused after %d seconds' do x_focused_window_id == x_client.window_id diff --git a/lib/uh/wm/actions_handler.rb b/lib/uh/wm/actions_handler.rb index 01b7ab2..dc5cf2a 100644 --- a/lib/uh/wm/actions_handler.rb +++ b/lib/uh/wm/actions_handler.rb @@ -38,6 +38,10 @@ module Uh Process.waitpid pid end + def kill_current + layout.current_client.kill + end + def log_separator log '- ' * 24 end diff --git a/spec/uh/wm/actions_handler_spec.rb b/spec/uh/wm/actions_handler_spec.rb index dcaa238..ce15031 100644 --- a/spec/uh/wm/actions_handler_spec.rb +++ b/spec/uh/wm/actions_handler_spec.rb @@ -24,6 +24,21 @@ module Uh end end + describe '#kill_current' do + let(:client) { instance_spy Client } + + context 'when layout has a client' do + before do + allow(actions.layout).to receive(:current_client) { client } + end + + it 'kills layout current client' do + expect(client).to receive :kill + actions.kill_current + end + end + end + describe '#log_separator' do it 'logs a separator' do expect(env).to receive(:log).with /(?:- ){20,}/