Ensure only one client is managed for given window
This commit is contained in:
parent
036ca1f989
commit
bdbeca399a
14
features/manager/manage.feature
Normal file
14
features/manager/manage.feature
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
Feature: manager client management
|
||||||
|
|
||||||
|
Background:
|
||||||
|
Given uhwm is running
|
||||||
|
|
||||||
|
Scenario: logs when a new client is managed
|
||||||
|
When a window requests to be mapped
|
||||||
|
Then the output must match /manage.+xclient/i
|
||||||
|
|
||||||
|
Scenario: manages a given client only once
|
||||||
|
When a window requests to be mapped 2 times
|
||||||
|
And I quit uhwm
|
||||||
|
Then the output must not match /manage.*\n.*manage/mi
|
||||||
|
And the output must not match /xerror/i
|
@ -23,6 +23,10 @@ Then /^the output must match \/([^\/]+)\/([a-z]*)$/ do |pattern, options|
|
|||||||
uhwm_wait_output Regexp.new(pattern, options)
|
uhwm_wait_output Regexp.new(pattern, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Then /^the output must not match \/([^\/]+)\/([a-z]*)$/ do |pattern, options|
|
||||||
|
expect(all_output).not_to match Regexp.new(pattern, options)
|
||||||
|
end
|
||||||
|
|
||||||
Then /^the output must contain:$/ do |content|
|
Then /^the output must contain:$/ do |content|
|
||||||
uhwm_wait_output content.to_s
|
uhwm_wait_output content.to_s
|
||||||
end
|
end
|
||||||
|
@ -27,6 +27,11 @@ When /^I tell uhwm to quit$/ do
|
|||||||
x_key 'alt+shift+q'
|
x_key 'alt+shift+q'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
When /^I quit uhwm$/ do
|
||||||
|
x_key 'alt+shift+q'
|
||||||
|
assert_exit_status 0
|
||||||
|
end
|
||||||
|
|
||||||
Then /^the exit status must be (\d+)$/ do |exit_status|
|
Then /^the exit status must be (\d+)$/ do |exit_status|
|
||||||
assert_exit_status exit_status.to_i
|
assert_exit_status exit_status.to_i
|
||||||
end
|
end
|
||||||
|
@ -6,6 +6,10 @@ When /^a window requests to be mapped$/ do
|
|||||||
x_window_map
|
x_window_map
|
||||||
end
|
end
|
||||||
|
|
||||||
|
When /^a window requests to be mapped (\d+) times$/ do |times|
|
||||||
|
x_window_map times: times.to_i
|
||||||
|
end
|
||||||
|
|
||||||
Then /^it must connect to X display$/ do
|
Then /^it must connect to X display$/ do
|
||||||
uhwm_wait_output 'Connected to'
|
uhwm_wait_output 'Connected to'
|
||||||
expect(x_socket_check uhwm_pid).to be true
|
expect(x_socket_check uhwm_pid).to be true
|
||||||
|
@ -46,7 +46,7 @@ module Uh
|
|||||||
end
|
end
|
||||||
|
|
||||||
def manage window
|
def manage window
|
||||||
return if window.override_redirect?
|
return if window.override_redirect? || client_for(window)
|
||||||
@clients << client = Client.new(window)
|
@clients << client = Client.new(window)
|
||||||
@events.emit :manage, args: client
|
@events.emit :manage, args: client
|
||||||
end
|
end
|
||||||
@ -83,6 +83,10 @@ module Uh
|
|||||||
manage event.window
|
manage event.window
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def client_for window
|
||||||
|
@clients.find { |e| e.window == window }
|
||||||
|
end
|
||||||
|
|
||||||
def check_other_wm!
|
def check_other_wm!
|
||||||
Display.on_error { fail OtherWMRunningError }
|
Display.on_error { fail OtherWMRunningError }
|
||||||
@display.listen_events INPUT_MASK
|
@display.listen_events INPUT_MASK
|
||||||
|
@ -89,8 +89,9 @@ module Uh
|
|||||||
@x_client.window_name
|
@x_client.window_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def x_window_map
|
def x_window_map times: 1
|
||||||
x_client.map.sync
|
times.times { x_client.map }
|
||||||
|
x_client.sync
|
||||||
end
|
end
|
||||||
|
|
||||||
def x_window_map_state
|
def x_window_map_state
|
||||||
|
@ -116,6 +116,11 @@ module Uh
|
|||||||
.and have_attributes(window: window)
|
.and have_attributes(window: window)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'registers new client only once for a given window' do
|
||||||
|
manager.manage window
|
||||||
|
expect { manager.manage window }.not_to change { manager.clients }
|
||||||
|
end
|
||||||
|
|
||||||
it 'ignores event when window has override redirect' do
|
it 'ignores event when window has override redirect' do
|
||||||
allow(window).to receive(:override_redirect?) { true }
|
allow(window).to receive(:override_redirect?) { true }
|
||||||
expect { manager.manage window }.not_to change { manager.clients }
|
expect { manager.manage window }.not_to change { manager.clients }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user