uh 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e23c0e6ca2adc65543ea88a899d518a66f6ba87d
4
- data.tar.gz: ecda150aaa445463377e82efa6ff16c260fb4cab
3
+ metadata.gz: 0efbb3383d315de3572ecf957001d7dfa7324c03
4
+ data.tar.gz: ceaee1387cb5664f702c675a8009986a88e54eb0
5
5
  SHA512:
6
- metadata.gz: 38c121dd15a0616f48b32aec6f2961e2e2393d7a4216e1d9ae712a0cd354b77e48ff602a631746e1b44695669cb113e57dc8f2c580b47a3ce593a656ac97fee4
7
- data.tar.gz: 0363cabe4cab460b7a94d29ec85f2c04fb93a523f6e615771f5d360438bfc6058dc2a92b13abd3c5175e6a8ff04ee00072fe3227aed8a4fe99270f6980d11d98
6
+ metadata.gz: d4f92d07c0f1356951d45e44544ca4b113f3f0e4efa5f8db2728b86d4db9f197e868786cd25a6b0eb027fbb1dbc9458dd2fbe372bf8d4a2820ffcaea3bf1d30b
7
+ data.tar.gz: 9d09c9409e9c83a65ad950c151fd0ee832effd5537a0c47506381de23f5ff9c1f4727d4a3e742c22812a7d4062ef125a67060baa7b06949a34452763d8249d7e
data/lib/uh/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Uh
2
- VERSION = '1.1.0'.freeze
2
+ VERSION = '1.1.1'.freeze
3
3
  end
@@ -1,44 +1,55 @@
1
1
  module Uh
2
2
  class WM
3
3
  class ActionHandler
4
+ extend Forwardable
5
+ def_delegators :@wm, :log, :log_error
6
+
7
+ attr_reader :layout
8
+
4
9
  def initialize(wm, manager, layout)
5
10
  @wm, @manager, @layout = wm, manager, layout
6
11
  end
7
12
 
8
13
  def call(action)
9
14
  instance_exec &action
15
+ rescue LocalJumpError => e
16
+ log_error "Action: #{e}"
10
17
  end
11
18
 
12
19
  def quit
13
- @wm.log 'Exiting...'
20
+ log 'Exiting...'
14
21
  @wm.request_quit!
15
22
  end
16
23
 
17
24
  def execute(command)
18
- @wm.log "Spawn `#{command}`"
25
+ log "Spawn `#{command}`"
19
26
  pid = spawn command, pgroup: true
20
27
  Process.detach pid
21
28
  rescue Errno::ENOENT => e
22
- @wm.log_error "Spawn: #{e}"
29
+ log_error "Spawn: #{e}"
23
30
  end
24
31
 
25
32
  def log_layout
26
- @wm.log "Layout:\n#{@layout.to_s.lines.map { |e| " #{e}" }.join.chomp}"
33
+ log "Layout:\n#{@layout.to_s.lines.map { |e| " #{e}" }.join.chomp}"
27
34
  end
28
35
 
29
36
  def log_clients
30
- @wm.log "Clients:\n#{@manager.to_s.lines.map { |e| " #{e}" }.join.chomp}"
37
+ log "Clients:\n#{@manager.to_s.lines.map { |e| " #{e}" }.join.chomp}"
31
38
  end
32
39
 
33
40
  def log_separator
34
- @wm.log '- ' * 24
41
+ log '- ' * 24
35
42
  end
36
43
 
37
44
  def method_missing(m, *args, &block)
38
45
  if respond_to? m
39
46
  meth = layout_method m
40
- @wm.log "#{@layout.class.name}##{meth} #{args.inspect}"
41
- @layout.send(meth, *args)
47
+ log "#{@layout.class.name}##{meth} #{args.inspect}"
48
+ begin
49
+ @layout.send(meth, *args)
50
+ rescue NoMethodError
51
+ log_error "Layout does not implement `#{meth}'"
52
+ end
42
53
  else
43
54
  super
44
55
  end
@@ -4,23 +4,27 @@ module Uh
4
4
  class MultiplexingWorker < BaseWorker
5
5
  DEFAULT_TIMEOUT = 4
6
6
 
7
- def configure(timeout: DEFAULT_TIMEOUT)
8
- @timeout = timeout
7
+ def configure(timeout: DEFAULT_TIMEOUT, on_timeout: nil)
8
+ @timeout = timeout
9
+ @on_timeout = on_timeout
9
10
  end
10
11
 
11
12
  def setup
12
13
  @display_io = IO.new(@display.fileno)
13
- @display.flush
14
14
  self
15
15
  end
16
16
 
17
17
  def each_event
18
18
  loop do
19
+ @display.flush
19
20
  @logger.debug "select [#{@display_io.fileno}], _, _, #{@timeout}"
20
21
  rs, _ = IO.select [@display_io], [], [], @timeout
21
22
  @logger.debug " => #{rs.inspect}"
22
- next if rs.nil? || rs.empty?
23
- yield @display.next_event while @display.pending?
23
+ if rs.nil? || rs.empty?
24
+ @on_timeout.call if @on_timeout
25
+ else
26
+ yield @display.next_event while @display.pending?
27
+ end
24
28
  end
25
29
  end
26
30
  end
data/lib/uh/wm.rb CHANGED
@@ -149,7 +149,7 @@ module Uh
149
149
 
150
150
  def log_event(event)
151
151
  complement = case event.type
152
- when :destroy_notify, :expose, :key_press, :map_request, :property_notify
152
+ when :destroy_notify, :expose, :map_request, :property_notify
153
153
  "window: #{event.window}"
154
154
  when :configure_request
155
155
  '%s, above: #%d, detail: #%d, value_mask: #%d' % [
@@ -158,6 +158,8 @@ module Uh
158
158
  event.detail,
159
159
  event.value_mask
160
160
  ]
161
+ when :key_press
162
+ "window: #{event.window}, key: #{event.key}, mask: #{event.modifier_mask}"
161
163
  when :unmap_notify
162
164
  "window: #{event.window}, event_window: #{event.event_window}"
163
165
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uh
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibault Jouan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-16 00:00:00.000000000 Z
11
+ date: 2015-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake