uh 0.1.8 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/uh/version.rb +1 -1
- data/lib/uh/wm.rb +33 -37
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9999e12b354d336f1ce29125beee2449b14605a7
|
4
|
+
data.tar.gz: 49554e1f41407b9a7a80b2f620858668783fde85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ee9bc0537a9451c13d48a68f1f3fea3ed4eeb1e881cfb6a9faf801285883425aaa94ebc2e94d79484939c6eef68b382a913d0fe356ef0f243c16cf5313538ceb
|
7
|
+
data.tar.gz: e967087ea493695022b163eb560905dd7ca74e6b6a1bf69d73b4422db9910a9cb403c03a1bca860861c3813c71008d26f04e1bf5171396fd3a17338c78f0a904
|
data/lib/uh/version.rb
CHANGED
data/lib/uh/wm.rb
CHANGED
@@ -42,9 +42,9 @@ module Uh
|
|
42
42
|
def_delegator :@logger, :info, :log
|
43
43
|
def_delegator :@logger, :error, :log_error
|
44
44
|
|
45
|
-
attr_reader :keys, :rules
|
45
|
+
attr_reader :actions, :keys, :rules
|
46
46
|
|
47
|
-
def initialize(layout
|
47
|
+
def initialize(layout)
|
48
48
|
@layout = layout
|
49
49
|
@display = Display.new
|
50
50
|
@logger = Logger.new($stdout).tap do |o|
|
@@ -52,11 +52,9 @@ module Uh
|
|
52
52
|
o.formatter = LOGGER_FORMATER
|
53
53
|
end
|
54
54
|
@manager = Manager.new(@logger)
|
55
|
+
@actions = ActionHandler.new(self, @manager, @layout)
|
55
56
|
@keys = {}
|
56
57
|
@rules = {}
|
57
|
-
|
58
|
-
return unless block_given?
|
59
|
-
if block.arity == 1 then yield self else instance_eval &block end
|
60
58
|
end
|
61
59
|
|
62
60
|
def modifier(mod = nil)
|
@@ -70,7 +68,7 @@ module Uh
|
|
70
68
|
@keys[[key, mod_mask]] = block
|
71
69
|
end
|
72
70
|
|
73
|
-
def rule(selectors, &block)
|
71
|
+
def rule(selectors = '', &block)
|
74
72
|
[*selectors].each do |selector|
|
75
73
|
@rules[/\A#{selector}/i] = block
|
76
74
|
end
|
@@ -85,40 +83,13 @@ module Uh
|
|
85
83
|
end
|
86
84
|
|
87
85
|
def worker(*args, **options)
|
88
|
-
@worker
|
89
|
-
WORKERS[args.first].new(@display, @logger, options)
|
90
|
-
else
|
91
|
-
Workers::BlockingWorker.new(@display, @logger)
|
92
|
-
end
|
86
|
+
@worker = WORKERS[args.first].new(@display, @logger, options)
|
93
87
|
end
|
94
88
|
|
95
89
|
def request_quit!
|
96
90
|
@quit_requested = true
|
97
91
|
end
|
98
92
|
|
99
|
-
def run
|
100
|
-
connect
|
101
|
-
@on_init.call @display
|
102
|
-
grab_keys
|
103
|
-
@display.root.mask = ROOT_MASK
|
104
|
-
worker.setup.each_event do |e|
|
105
|
-
process_event e
|
106
|
-
break if quit_requested?
|
107
|
-
end
|
108
|
-
disconnect
|
109
|
-
end
|
110
|
-
|
111
|
-
|
112
|
-
private
|
113
|
-
|
114
|
-
def modifier_mask(mod)
|
115
|
-
KEY_MODIFIERS[mod]
|
116
|
-
end
|
117
|
-
|
118
|
-
def quit_requested?
|
119
|
-
!!@quit_requested
|
120
|
-
end
|
121
|
-
|
122
93
|
def connect
|
123
94
|
@display.open
|
124
95
|
Display.on_error proc { fail OtherWMRunningError }
|
@@ -126,6 +97,9 @@ module Uh
|
|
126
97
|
@display.sync false
|
127
98
|
Display.on_error proc { |*args| handle_error(*args) }
|
128
99
|
@display.sync false
|
100
|
+
@display.root.mask = ROOT_MASK
|
101
|
+
@worker.setup
|
102
|
+
@on_init.call @display if @on_init
|
129
103
|
end
|
130
104
|
|
131
105
|
def disconnect
|
@@ -138,6 +112,29 @@ module Uh
|
|
138
112
|
key = key.to_s.gsub /\AXK_/, ''
|
139
113
|
@display.grab_key key, mod
|
140
114
|
end
|
115
|
+
@display.sync false
|
116
|
+
end
|
117
|
+
|
118
|
+
def run_until(&block)
|
119
|
+
@worker.each_event do |e|
|
120
|
+
process_event e
|
121
|
+
break if block.call
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def run
|
126
|
+
run_until { quit_requested? }
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
private
|
131
|
+
|
132
|
+
def modifier_mask(mod)
|
133
|
+
KEY_MODIFIERS[mod]
|
134
|
+
end
|
135
|
+
|
136
|
+
def quit_requested?
|
137
|
+
!!@quit_requested
|
141
138
|
end
|
142
139
|
|
143
140
|
def process_event(event)
|
@@ -183,8 +180,7 @@ module Uh
|
|
183
180
|
end
|
184
181
|
|
185
182
|
def handle_key_press(event)
|
186
|
-
|
187
|
-
.call @keys[["XK_#{event.key}".to_sym, event.modifier_mask]]
|
183
|
+
actions.call @keys[["XK_#{event.key}".to_sym, event.modifier_mask]]
|
188
184
|
end
|
189
185
|
|
190
186
|
def handle_map_request(event)
|
@@ -192,7 +188,7 @@ module Uh
|
|
192
188
|
@display.listen_events event.window, PROPERTY_CHANGE_MASK
|
193
189
|
@rules.each do |selector, action|
|
194
190
|
if client.wclass =~ selector
|
195
|
-
|
191
|
+
actions.call action
|
196
192
|
end
|
197
193
|
end
|
198
194
|
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: 0.
|
4
|
+
version: 1.0.0
|
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-
|
11
|
+
date: 2015-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|