uh-wm 0.0.8 → 0.0.9

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: a9e65ddc3d9f3e3f406b624138ef47c86531380e
4
- data.tar.gz: 095aac6361586080213412cb40d1ba6a7393150a
3
+ metadata.gz: d964f7fa9ddc317e9e179e07a20cd462457a7a80
4
+ data.tar.gz: 93baa823c8b9fbc18fef96b37ad79416daa7059e
5
5
  SHA512:
6
- metadata.gz: 3d3733270d72b481d05fded4c6bd0a66dcbdce5be277c639a6aba35ef613128276251f1795d70aa876ec375f85e7adc9d9da5ccf6a40576b6ff1aa1d38fa69da
7
- data.tar.gz: ec55836544feb58833aae7168adc823640a1dc5d27531a3d1af2b6d71442f6847b7aba9fc4906b78f06382eb178ee65a891813c14b9c267386953701d2478c8b
6
+ metadata.gz: 613887c13875de0901994d0dad1ff57ff4ba45f175fb149e0e6e6ef85ec1c7d9fc6d4faceb00e199ef40ec8c571f80c77bff4ef02bc355389dba9e6dd0b19936
7
+ data.tar.gz: 9182b6a47768f16bfe5e0fae1db0e8d3dc1f6f75b3213ba267842025a3cabb7e39144f7f8173f8e805389e8cf01ec8b614a5c5eb15e29d0811b4d10bce240e02
data/lib/uh/wm.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'forwardable'
2
2
  require 'logger'
3
3
  require 'optparse'
4
- require 'rb-kqueue'
4
+ require 'rbconfig'
5
5
  require 'uh'
6
6
 
7
7
  require 'uh/wm/env_logging'
@@ -20,7 +20,7 @@ require 'uh/wm/version'
20
20
  require 'uh/wm/workers'
21
21
  require 'uh/wm/workers/base'
22
22
  require 'uh/wm/workers/blocking'
23
- require 'uh/wm/workers/kqueue'
23
+ require 'uh/wm/workers/kqueue' unless RbConfig::CONFIG['host_os'] =~ /linux/i
24
24
  require 'uh/wm/workers/mux'
25
25
 
26
26
  module Uh
data/lib/uh/wm/env.rb CHANGED
@@ -23,15 +23,16 @@ module Uh
23
23
 
24
24
  attr_reader :output, :keybinds
25
25
  attr_accessor :verbose, :debug, :rc_path, :modifier, :worker,
26
- :layout, :layout_class, :rules, :launch
26
+ :layout, :layout_class, :layout_options, :rules, :launch
27
27
 
28
28
  def initialize output
29
- @output = output
30
- @rc_path = RC_PATH
31
- @modifier = MODIFIER
32
- @keybinds = KEYBINDS.dup
33
- @worker = :block
34
- @rules = {}
29
+ @output = output
30
+ @rc_path = RC_PATH
31
+ @modifier = MODIFIER
32
+ @keybinds = KEYBINDS.dup
33
+ @layout_options = {}
34
+ @worker = :block
35
+ @rules = {}
35
36
  end
36
37
 
37
38
  def verbose?
@@ -44,10 +45,10 @@ module Uh
44
45
 
45
46
  def layout
46
47
  @layout ||= if layout_class
47
- layout_class.new
48
+ layout_class.new @layout_options
48
49
  else
49
50
  require 'uh/layout'
50
- ::Uh::Layout.new
51
+ ::Uh::Layout.new(@layout_options)
51
52
  end
52
53
  end
53
54
 
@@ -35,12 +35,15 @@ module Uh
35
35
  end
36
36
 
37
37
  def layout arg, **options
38
- if arg.is_a? Class
38
+ case arg
39
+ when Class
39
40
  if options.any?
40
41
  @env.layout = arg.new options
41
42
  else
42
43
  @env.layout_class = arg
43
44
  end
45
+ when Hash
46
+ @env.layout_options = arg
44
47
  else
45
48
  @env.layout = arg
46
49
  end
data/lib/uh/wm/runner.rb CHANGED
@@ -57,11 +57,12 @@ module Uh
57
57
 
58
58
  def worker
59
59
  @worker ||= Workers.build(*(@env.worker)).tap do |w|
60
- w.before_watch { @manager.handle_pending_events }
60
+ w.before_watch { @manager.flush }
61
61
  w.on_read { @manager.handle_pending_events }
62
62
  w.on_read_next { @manager.handle_next_event }
63
- w.on_timeout do |*args|
64
- log_debug "Worker timeout: #{args.inspect}"
63
+ w.on_timeout do
64
+ log_debug "Worker timeout, ticking..."
65
+ @events.emit :tick
65
66
  log_debug 'Flushing X output buffer'
66
67
  @manager.flush
67
68
  end
@@ -129,6 +130,7 @@ module Uh
129
130
  log "Exposing window: #{window}"
130
131
  layout.expose window
131
132
  end
133
+ @events.on(:tick) { layout.update }
132
134
  end
133
135
 
134
136
  def register_keybinds_hooks
data/lib/uh/wm/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  module Uh
2
2
  module WM
3
- VERSION = '0.0.8'
3
+ VERSION = '0.0.9'
4
4
  end
5
5
  end
@@ -1,3 +1,5 @@
1
+ require 'rb-kqueue'
2
+
1
3
  module Uh
2
4
  module WM
3
5
  module Workers
@@ -6,24 +8,30 @@ module Uh
6
8
 
7
9
  def initialize timeout: TIMEOUT_DEFAULT
8
10
  super
9
- @queue = ::KQueue::Queue.new
11
+ @timeout = timeout * 1000
10
12
  end
11
13
 
12
- def watch io
13
- @queue.watch_stream_for_read io.to_io do
14
- @on_read.call
15
- end
14
+ def work_events
15
+ @before_watch.call if @before_watch
16
+ queue.run
16
17
  end
17
18
 
18
- def on_timeout &block
19
- ::KQueue::Watcher.new(@queue, 1, :timer, [], 1000, proc do |event|
20
- block.call
21
- end)
22
- end
23
19
 
24
- def work_events
25
- @before_watch.call if @before_watch
26
- events = @queue.process
20
+ private
21
+
22
+ def queue
23
+ @queue ||= ::KQueue::Queue.new.tap do |q|
24
+ @ios.each do |io|
25
+ ::KQueue::Watcher.new(q, io.fileno, :read, [], nil, proc do |_|
26
+ q.stop
27
+ @on_read.call
28
+ end)
29
+ end
30
+ ::KQueue::Watcher.new(q, 1, :timer, [], @timeout, proc do |_|
31
+ q.stop
32
+ @on_timeout.call
33
+ end)
34
+ end
27
35
  end
28
36
  end
29
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uh-wm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
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-05-21 00:00:00.000000000 Z
11
+ date: 2015-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rb-kqueue
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.4.0
47
+ version: 0.4.2
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.4.0
54
+ version: 0.4.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: aruba
57
57
  requirement: !ruby/object:Gem::Requirement