Merge branch 'window-destroy-handling'
This commit is contained in:
commit
3849471a1b
@ -1,7 +1,13 @@
|
|||||||
Feature: manager client unmanagement
|
Feature: manager client unmanagement
|
||||||
|
|
||||||
Scenario: logs when a new client is unmanaged
|
Background:
|
||||||
Given uhwm is running
|
Given uhwm is running
|
||||||
And a window is mapped
|
And a window is mapped
|
||||||
|
|
||||||
|
Scenario: logs when a new client is unmanaged
|
||||||
When the window requests to be unmapped
|
When the window requests to be unmapped
|
||||||
Then the output must match /unmanag.+xclient/i
|
Then the output must match /unmanag.+xclient/i
|
||||||
|
|
||||||
|
Scenario: unmanages client on destroy notify X events
|
||||||
|
When the window is destroyed
|
||||||
|
Then the output must match /unmanag.+xclient/i
|
||||||
|
@ -26,6 +26,10 @@ When /^a window requests to be mapped (\d+) times$/ do |times|
|
|||||||
x_window_map times: times.to_i
|
x_window_map times: times.to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
|
When /^the window is destroyed$/ do
|
||||||
|
x_window_destroy
|
||||||
|
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
|
||||||
|
@ -71,6 +71,12 @@ module Uh
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy window
|
||||||
|
return unless client = client_for(window)
|
||||||
|
@clients.delete client
|
||||||
|
@events.emit :unmanage, args: client
|
||||||
|
end
|
||||||
|
|
||||||
def handle_next_event
|
def handle_next_event
|
||||||
handle @display.next_event
|
handle @display.next_event
|
||||||
end
|
end
|
||||||
@ -103,6 +109,10 @@ module Uh
|
|||||||
configure event.window
|
configure event.window
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def handle_destroy_notify event
|
||||||
|
destroy event.window
|
||||||
|
end
|
||||||
|
|
||||||
def handle_map_request event
|
def handle_map_request event
|
||||||
map event.window
|
map event.window
|
||||||
end
|
end
|
||||||
|
@ -106,6 +106,11 @@ module Uh
|
|||||||
x_client(options).sync
|
x_client(options).sync
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def x_window_destroy **options
|
||||||
|
x_client(options).destroy
|
||||||
|
x_client(options).sync
|
||||||
|
end
|
||||||
|
|
||||||
def x_clients_ensure_stop
|
def x_clients_ensure_stop
|
||||||
@x_clients and @x_clients.any? and @x_clients.values.each &:terminate
|
@x_clients and @x_clients.any? and @x_clients.values.each &:terminate
|
||||||
end
|
end
|
||||||
@ -177,6 +182,11 @@ module Uh
|
|||||||
window.unmap
|
window.unmap
|
||||||
self
|
self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
window.destroy
|
||||||
|
self
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -214,6 +214,35 @@ module Uh
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#destroy' do
|
||||||
|
before { manager.map window }
|
||||||
|
|
||||||
|
it 'unregisters the client' do
|
||||||
|
expect { manager.destroy window }
|
||||||
|
.to change { manager.clients.size }.from(1).to 0
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'emits :unmanage event with the client' do
|
||||||
|
events.on :unmanage, &block
|
||||||
|
expect(block).to receive(:call).with manager.clients[0]
|
||||||
|
manager.destroy window
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with unknown window' do
|
||||||
|
let(:unknown_window) { window.dup }
|
||||||
|
|
||||||
|
it 'does not change registered clients' do
|
||||||
|
expect { manager.destroy unknown_window }
|
||||||
|
.not_to change { manager.clients }
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not emit any event' do
|
||||||
|
expect(events).not_to receive :emit
|
||||||
|
manager.destroy unknown_window
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#handle_next_event' do
|
describe '#handle_next_event' do
|
||||||
it 'handles the next available event on display' do
|
it 'handles the next available event on display' do
|
||||||
event = double 'event'
|
event = double 'event'
|
||||||
@ -294,6 +323,15 @@ module Uh
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when destroy_notify event is given' do
|
||||||
|
let(:event) { double 'event', type: :destroy_notify, window: :window }
|
||||||
|
|
||||||
|
it 'destroy the event window' do
|
||||||
|
expect(manager).to receive(:destroy).with :window
|
||||||
|
manager.handle event
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'when map_request event is given' do
|
context 'when map_request event is given' do
|
||||||
let(:event) { double 'event', type: :map_request, window: :window }
|
let(:event) { double 'event', type: :map_request, window: :window }
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|||||||
s.test_files = s.files.grep /\A(spec|features)\//
|
s.test_files = s.files.grep /\A(spec|features)\//
|
||||||
s.executables = s.files.grep(/\Abin\//) { |f| File.basename(f) }
|
s.executables = s.files.grep(/\Abin\//) { |f| File.basename(f) }
|
||||||
|
|
||||||
s.add_dependency 'uh', '2.0.0.pre1'
|
s.add_dependency 'uh', '2.0.0.pre2'
|
||||||
s.add_dependency 'uh-layout', '0.2.0.pre'
|
s.add_dependency 'uh-layout', '0.2.0.pre'
|
||||||
|
|
||||||
s.add_development_dependency 'aruba', '~> 0.6'
|
s.add_development_dependency 'aruba', '~> 0.6'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user