Register clients in manager on map requests
This commit is contained in:
parent
6e90225c9d
commit
a0dcca07f9
@ -7,12 +7,13 @@ module Uh
|
||||
Events::SUBSTRUCTURE_NOTIFY_MASK |
|
||||
Events::STRUCTURE_NOTIFY_MASK
|
||||
|
||||
attr_reader :modifier, :display
|
||||
attr_reader :modifier, :display, :clients
|
||||
|
||||
def initialize events, modifier, display = Display.new
|
||||
@events = events
|
||||
@modifier = modifier
|
||||
@display = display
|
||||
@clients = []
|
||||
end
|
||||
|
||||
def connect
|
||||
@ -50,7 +51,8 @@ module Uh
|
||||
event.key.to_sym
|
||||
@events.emit :key, *key_selector
|
||||
when :map_request
|
||||
@events.emit :manage, args: event.window
|
||||
@clients << client = Client.new(event.window)
|
||||
@events.emit :manage, args: client
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -11,6 +11,10 @@ module Uh
|
||||
expect(manager.display).to be_a Display
|
||||
end
|
||||
|
||||
it 'has no clients' do
|
||||
expect(manager.clients).to be_empty
|
||||
end
|
||||
|
||||
describe '#connect', :xvfb do
|
||||
it 'opens the display' do
|
||||
expect(manager.display).to receive(:open).and_call_original
|
||||
@ -139,12 +143,22 @@ module Uh
|
||||
context 'when map_request event is given' do
|
||||
let(:event) { double 'event', type: :map_request, window: :window }
|
||||
|
||||
it 'emits :manage event' do
|
||||
events.on(:manage) { throw :manage_code }
|
||||
expect { manager.handle event }.to throw_symbol :manage_code
|
||||
it 'registers a new client wrapping the event window' do
|
||||
manager.handle event
|
||||
expect(manager.clients[0])
|
||||
.to be_a(Client)
|
||||
.and have_attributes(window: :window)
|
||||
end
|
||||
|
||||
it 'emits :manage event with the client'
|
||||
it 'emits :manage event with the registered client' do
|
||||
events.on :manage, &block
|
||||
expect(block).to receive :call do |client|
|
||||
expect(client)
|
||||
.to be_a(Client)
|
||||
.and have_attributes(window: :window)
|
||||
end
|
||||
manager.handle event
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user