Class: Uh::WM::Manager

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/uh/wm/manager.rb

Constant Summary collapse

DEFAULT_GEO =
Geo.new(0, 0, 320, 240).freeze

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ Manager

Returns a new instance of Manager.



9
10
11
12
# File 'lib/uh/wm/manager.rb', line 9

def initialize(logger)
  @logger     = logger
  @clients    = []
end

Instance Method Details

#configure(window) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
# File 'lib/uh/wm/manager.rb', line 34

def configure(window)
  if client = client_for(window)
    log "#{self.class.name}#configure #{client} already managed"
    client.configure
  else
    geo = @on_configure ? @on_configure.call(window) : DEFAULT_GEO
    log "#{self.class.name}#configure window: #{window}, not managed"
    log "#{window.class.name}#configure #{geo}"
    window.configure_event geo
  end
end

#destroy(window) ⇒ Object



63
64
65
# File 'lib/uh/wm/manager.rb', line 63

def destroy(window)
  remove_client_for window
end

#map(window) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/uh/wm/manager.rb', line 46

def map(window)
  if window.override_redirect?
    log "#{self.class.name}#map #{window}.override_redirect, skipping"
    return
  end

  if client = client_for(window)
    log "#{self.class.name}#map #{client}, already managed"
    nil
  else
    Client.new(window).tap { |o| manage o }
  end
end

#on_change(&block) ⇒ Object



30
31
32
# File 'lib/uh/wm/manager.rb', line 30

def on_change(&block)
  @on_change = block
end

#on_configure(&block) ⇒ Object



18
19
20
# File 'lib/uh/wm/manager.rb', line 18

def on_configure(&block)
  @on_configure = block
end

#on_manage(&block) ⇒ Object



22
23
24
# File 'lib/uh/wm/manager.rb', line 22

def on_manage(&block)
  @on_manage = block
end

#on_unmanage(&block) ⇒ Object



26
27
28
# File 'lib/uh/wm/manager.rb', line 26

def on_unmanage(&block)
  @on_unmanage = block
end

#to_sObject



14
15
16
# File 'lib/uh/wm/manager.rb', line 14

def to_s
  @clients.join $/
end

#unmap(window) ⇒ Object



60
61
# File 'lib/uh/wm/manager.rb', line 60

def unmap(window)
end

#update_properties(window) ⇒ Object



67
68
69
70
71
# File 'lib/uh/wm/manager.rb', line 67

def update_properties(window)
  return unless client = client_for(window)
  client.update_window_properties
  @on_change.call client if @on_change
end