Implement Manager#configure
This commit is contained in:
parent
7fc695f258
commit
1f7b2269c7
@ -6,6 +6,7 @@ module Uh
|
||||
Events::SUBSTRUCTURE_REDIRECT_MASK |
|
||||
Events::SUBSTRUCTURE_NOTIFY_MASK |
|
||||
Events::STRUCTURE_NOTIFY_MASK
|
||||
DEFAULT_GEO = Geo.new(0, 0, 320, 240).freeze
|
||||
|
||||
attr_reader :modifier, :display, :clients
|
||||
|
||||
@ -45,6 +46,15 @@ module Uh
|
||||
@display.grab_key keysym.to_s, mod_mask
|
||||
end
|
||||
|
||||
def configure window
|
||||
if client = client_for(window)
|
||||
client.configure
|
||||
else
|
||||
geo = @events.emit :configure, args: window
|
||||
window.configure_event geo ? geo : DEFAULT_GEO
|
||||
end
|
||||
end
|
||||
|
||||
def manage window
|
||||
return if window.override_redirect? || client_for(window)
|
||||
@clients << client = Client.new(window)
|
||||
|
@ -2,6 +2,7 @@ module Uh
|
||||
module WM
|
||||
RSpec.describe Manager do
|
||||
let(:block) { proc { } }
|
||||
let(:window) { instance_spy Window, override_redirect?: false }
|
||||
let(:events) { Dispatcher.new }
|
||||
let(:modifier) { :mod1 }
|
||||
let(:display) { Display.new }
|
||||
@ -106,9 +107,35 @@ module Uh
|
||||
end
|
||||
end
|
||||
|
||||
describe '#manage' do
|
||||
let(:window) { instance_spy Window, override_redirect?: false }
|
||||
describe '#configure' do
|
||||
context 'with new window' do
|
||||
it 'sends a configure event to the window with a default geo' do
|
||||
expect(window)
|
||||
.to receive(:configure_event).with(Geo.new(0, 0, 320, 240))
|
||||
manager.configure window
|
||||
end
|
||||
|
||||
context 'when :configure event returns a geo' do
|
||||
it 'sends a configure event with geo returned by event' do
|
||||
geo = Geo.new(0, 0, 42, 42)
|
||||
events.on(:configure) { geo }
|
||||
expect(window).to receive(:configure_event).with geo
|
||||
manager.configure window
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'with known window' do
|
||||
before { manager.manage window }
|
||||
|
||||
it 'tells the client to configure' do
|
||||
expect(manager.clients[0]).to receive :configure
|
||||
manager.configure window
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#manage' do
|
||||
it 'registers a new client wrapping the given window' do
|
||||
manager.manage window
|
||||
expect(manager.clients[0])
|
||||
|
Loading…
x
Reference in New Issue
Block a user