active_window_x 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +25 -0
- data/Gemfile +6 -0
- data/LICENSE +22 -0
- data/README.md +60 -0
- data/Rakefile +47 -0
- data/active_window_x.gemspec +22 -0
- data/ext/active_window_x/extconf.rb +7 -0
- data/ext/active_window_x/xlib.c +751 -0
- data/lib/active_window_x/atom.rb +30 -0
- data/lib/active_window_x/client_message_event.rb +44 -0
- data/lib/active_window_x/display.rb +79 -0
- data/lib/active_window_x/event.rb +15 -0
- data/lib/active_window_x/event_listener.rb +119 -0
- data/lib/active_window_x/property_event.rb +46 -0
- data/lib/active_window_x/root_window.rb +20 -0
- data/lib/active_window_x/version.rb +3 -0
- data/lib/active_window_x/window.rb +123 -0
- data/lib/active_window_x/xid.rb +29 -0
- data/lib/active_window_x.rb +30 -0
- data/sample/active_window_dump.rb +30 -0
- data/sample/simple.rb +6 -0
- data/spec/atom_spec.rb +27 -0
- data/spec/display_spec.rb +63 -0
- data/spec/root_window_spec.rb +47 -0
- data/spec/window_spec.rb +285 -0
- data/spec/xlib_spec.rb +245 -0
- metadata +136 -0
data/.gitignore
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
*.o
|
4
|
+
*.so
|
5
|
+
*.dll
|
6
|
+
*.bk
|
7
|
+
*.log
|
8
|
+
*~
|
9
|
+
.bundle
|
10
|
+
.config
|
11
|
+
.yardoc
|
12
|
+
Gemfile.lock
|
13
|
+
InstalledFiles
|
14
|
+
Makefile
|
15
|
+
_yardoc
|
16
|
+
core
|
17
|
+
coverage
|
18
|
+
doc/
|
19
|
+
lib/bundler/man
|
20
|
+
pkg
|
21
|
+
rdoc
|
22
|
+
spec/reports
|
23
|
+
test/tmp
|
24
|
+
test/version_tmp
|
25
|
+
tmp
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Keiichiro Ui
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# ActiveWindowX
|
2
|
+
|
3
|
+
ActiveWindowX is a gem to observe an active window on Linux (X Window System).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'active_window_x'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ apt-get install libx11-dev
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install active_window_x
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
The following script observe the active window and it's title changing.
|
23
|
+
|
24
|
+
```simple.rb
|
25
|
+
require 'active_window_x'
|
26
|
+
|
27
|
+
ActiveWindowX::EventListener.new do |e|
|
28
|
+
puts "#{e.type}:\t#{e.window}"
|
29
|
+
end
|
30
|
+
```
|
31
|
+
|
32
|
+
execute:
|
33
|
+
|
34
|
+
```
|
35
|
+
$ ruby simple.rb
|
36
|
+
# switch the active window or the browser tab!!
|
37
|
+
active_window: #<ActiveWindowX::Window:0x7fd47d391e18>
|
38
|
+
title: #<ActiveWindowX::Window:0x7fd47d391850>
|
39
|
+
title: #<ActiveWindowX::Window:0x7fd47d391030>
|
40
|
+
active_window: #<ActiveWindowX::Window:0x7fd47d390540>
|
41
|
+
active_window: #<ActiveWindowX::Window:0x7fd47d38fc30>
|
42
|
+
...
|
43
|
+
```
|
44
|
+
|
45
|
+
and see [other samples](https://github.com/kui/active_window_x/tree/master/sample)
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
1. Fork it
|
50
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
51
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
52
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
53
|
+
5. Create new Pull Request
|
54
|
+
|
55
|
+
## ToDo
|
56
|
+
|
57
|
+
* See `git grep TODO`
|
58
|
+
* Accessor API for the window icons
|
59
|
+
* Setter to select event types for listening
|
60
|
+
* `@continue` setter to terminate graceful
|
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core"
|
5
|
+
require "rspec/core/rake_task"
|
6
|
+
require 'rake/clean'
|
7
|
+
|
8
|
+
NAME = 'active_window_x'
|
9
|
+
MAKEFILES = Dir.glob "ext/**/Makefile"
|
10
|
+
|
11
|
+
## so file
|
12
|
+
file "lib/#{NAME}/xlib.so" =>
|
13
|
+
(Dir.glob("ext/#{NAME}/*.{rb,c}") << "lib/#{NAME}")do
|
14
|
+
|
15
|
+
Dir.chdir "ext/#{NAME}" do
|
16
|
+
ruby "extconf.rb"
|
17
|
+
sh "make"
|
18
|
+
end
|
19
|
+
|
20
|
+
cp "ext/#{NAME}/xlib.so", "lib/#{NAME}"
|
21
|
+
end
|
22
|
+
|
23
|
+
## make_clean
|
24
|
+
desc "do `make clean` with all Makefiles"
|
25
|
+
task :make_clean do
|
26
|
+
MAKEFILES.each do |file|
|
27
|
+
dir = File.dirname file
|
28
|
+
puts "cd #{dir}"
|
29
|
+
Dir.chdir dir do
|
30
|
+
sh "make clean"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
## clobber
|
36
|
+
CLOBBER.include "lib/**/*.so"
|
37
|
+
|
38
|
+
## clean
|
39
|
+
CLEAN.include MAKEFILES
|
40
|
+
task :clean => :make_clean
|
41
|
+
|
42
|
+
desc "Run all specs in spec/*_spec.rb"
|
43
|
+
task :spec => "lib/#{NAME}/xlib.so"
|
44
|
+
RSpec::Core::RakeTask.new :spec
|
45
|
+
|
46
|
+
task :build => :spec
|
47
|
+
task :default => :spec
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- coding:utf-8; mode:ruby; -*-
|
2
|
+
require File.expand_path('../lib/active_window_x/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Keiichiro Ui"]
|
6
|
+
gem.email = ["keiichiro.ui@gmail.com"]
|
7
|
+
gem.description = %q{ActiveWindowX is a gem to observe an active window on Linux (X Window System).}
|
8
|
+
gem.summary = %q{observer an active window on Linux (X Window System).}
|
9
|
+
gem.homepage = "https://github.com/kui/active_window_x"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.extensions = ['ext/active_window_x/extconf.rb']
|
13
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
+
gem.name = "active_window_x"
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
gem.version = ActiveWindowX::VERSION
|
18
|
+
|
19
|
+
gem.add_development_dependency 'rake'
|
20
|
+
gem.add_development_dependency 'bundler'
|
21
|
+
gem.add_development_dependency 'rspec'
|
22
|
+
end
|