imitator_x 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/COPYING.LESSER.rdoc +169 -0
 - data/COPYING.rdoc +678 -0
 - data/README.rdoc +70 -0
 - data/Rakefile.rb +99 -0
 - data/TODO.rdoc +8 -0
 - data/ext/clipboard.c +429 -0
 - data/ext/clipboard.h +61 -0
 - data/ext/extconf.rb +55 -0
 - data/ext/keyboard.c +711 -0
 - data/ext/keyboard.h +29 -0
 - data/ext/mouse.c +456 -0
 - data/ext/mouse.h +28 -0
 - data/ext/x.c +84 -0
 - data/ext/x.h +48 -0
 - data/ext/xwindow.c +1434 -0
 - data/ext/xwindow.h +38 -0
 - data/lib/imitator/x/drive.rb +179 -0
 - data/lib/imitator/x.rb +29 -0
 - data/lib/imitator_x_special_chars.yml +179 -0
 - data/test/test_clipboard.rb +46 -0
 - data/test/test_keyboard.rb +117 -0
 - data/test/test_mouse.rb +40 -0
 - data/test/test_xdrive.rb +47 -0
 - data/test/test_xwindow.rb +106 -0
 - metadata +123 -0
 
| 
         @@ -0,0 +1,106 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #!/usr/bin/env ruby
         
     | 
| 
      
 2 
     | 
    
         
            +
            #Encoding: UTF-8
         
     | 
| 
      
 3 
     | 
    
         
            +
            =begin
         
     | 
| 
      
 4 
     | 
    
         
            +
            --
         
     | 
| 
      
 5 
     | 
    
         
            +
            Imitator for X is a library allowing you to fake input to systems using X11. 
         
     | 
| 
      
 6 
     | 
    
         
            +
            Copyright © 2010 Marvin Gülker
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            This file is part of Imitator for X.
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            Imitator for X is free software: you can redistribute it and/or modify
         
     | 
| 
      
 11 
     | 
    
         
            +
            it under the terms of the GNU Lesser General Public License as published by
         
     | 
| 
      
 12 
     | 
    
         
            +
            the Free Software Foundation, either version 3 of the License, or
         
     | 
| 
      
 13 
     | 
    
         
            +
            (at your option) any later version.
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            Imitator for X is distributed in the hope that it will be useful,
         
     | 
| 
      
 16 
     | 
    
         
            +
            but WITHOUT ANY WARRANTY; without even the implied warranty of
         
     | 
| 
      
 17 
     | 
    
         
            +
            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
         
     | 
| 
      
 18 
     | 
    
         
            +
            GNU Lesser General Public License for more details.
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
            You should have received a copy of the GNU Lesser General Public License
         
     | 
| 
      
 21 
     | 
    
         
            +
            along with Imitator for X.  If not, see <http://www.gnu.org/licenses/>.
         
     | 
| 
      
 22 
     | 
    
         
            +
            ++
         
     | 
| 
      
 23 
     | 
    
         
            +
            =end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
            #Ensure we use the correct key combinations file
         
     | 
| 
      
 26 
     | 
    
         
            +
            $imitator_x_charfile_path = File.join(File.expand_path(File.dirname(__FILE__)), "..", "lib", "imitator_x_special_chars.yml")
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
            require "test/unit"
         
     | 
| 
      
 29 
     | 
    
         
            +
            require_relative "../lib/imitator/x"
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            class XWindowTest < Test::Unit::TestCase
         
     | 
| 
      
 32 
     | 
    
         
            +
              
         
     | 
| 
      
 33 
     | 
    
         
            +
              EDITOR = ["gedit", "kwrite", "mousepad", "kate"].find{|cmd| `which '#{cmd}'`; $?.exitstatus == 0}
         
     | 
| 
      
 34 
     | 
    
         
            +
              raise("No editor found!") if EDITOR.nil?
         
     | 
| 
      
 35 
     | 
    
         
            +
              puts "Chosen editor: '#{EDITOR}'." if $VERBOSE
         
     | 
| 
      
 36 
     | 
    
         
            +
              #~ p  Imitator::X::XWindow.from_title(Regexp.new(Regexp.escape(EDITOR)))
         
     | 
| 
      
 37 
     | 
    
         
            +
              
         
     | 
| 
      
 38 
     | 
    
         
            +
              def self.startup
         
     | 
| 
      
 39 
     | 
    
         
            +
                @@editor_pid = spawn(EDITOR)
         
     | 
| 
      
 40 
     | 
    
         
            +
                @@xwin = Imitator::X::XWindow.wait_for_window(Regexp.new(Regexp.escape(EDITOR)))
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
              
         
     | 
| 
      
 43 
     | 
    
         
            +
              def self.shutdown
         
     | 
| 
      
 44 
     | 
    
         
            +
                Process.kill("SIGKILL", @@editor_pid)
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
              
         
     | 
| 
      
 47 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 48 
     | 
    
         
            +
                sleep 0.5
         
     | 
| 
      
 49 
     | 
    
         
            +
              end
         
     | 
| 
      
 50 
     | 
    
         
            +
              
         
     | 
| 
      
 51 
     | 
    
         
            +
              def test_activate_unfocus
         
     | 
| 
      
 52 
     | 
    
         
            +
                @@xwin.activate
         
     | 
| 
      
 53 
     | 
    
         
            +
                sleep 2
         
     | 
| 
      
 54 
     | 
    
         
            +
                assert_equal(Imitator::X::XWindow.from_active, @@xwin)
         
     | 
| 
      
 55 
     | 
    
         
            +
                @@xwin.unfocus
         
     | 
| 
      
 56 
     | 
    
         
            +
                sleep 1
         
     | 
| 
      
 57 
     | 
    
         
            +
                assert_not_equal(@@xwin, Imitator::X::XWindow.from_focused)
         
     | 
| 
      
 58 
     | 
    
         
            +
              end
         
     | 
| 
      
 59 
     | 
    
         
            +
              
         
     | 
| 
      
 60 
     | 
    
         
            +
              def test_exists
         
     | 
| 
      
 61 
     | 
    
         
            +
                assert(@@xwin.exists?)
         
     | 
| 
      
 62 
     | 
    
         
            +
              end
         
     | 
| 
      
 63 
     | 
    
         
            +
              
         
     | 
| 
      
 64 
     | 
    
         
            +
              def test_map
         
     | 
| 
      
 65 
     | 
    
         
            +
                assert(@@xwin.mapped?)
         
     | 
| 
      
 66 
     | 
    
         
            +
                @@xwin.unmap
         
     | 
| 
      
 67 
     | 
    
         
            +
                sleep 1
         
     | 
| 
      
 68 
     | 
    
         
            +
                assert(!@@xwin.mapped?)
         
     | 
| 
      
 69 
     | 
    
         
            +
                @@xwin.map
         
     | 
| 
      
 70 
     | 
    
         
            +
                sleep 1
         
     | 
| 
      
 71 
     | 
    
         
            +
                assert(@@xwin.mapped?)
         
     | 
| 
      
 72 
     | 
    
         
            +
              end
         
     | 
| 
      
 73 
     | 
    
         
            +
              
         
     | 
| 
      
 74 
     | 
    
         
            +
              def test_parent
         
     | 
| 
      
 75 
     | 
    
         
            +
                assert_equal(@@xwin.root_win, @@xwin.parent)
         
     | 
| 
      
 76 
     | 
    
         
            +
              end
         
     | 
| 
      
 77 
     | 
    
         
            +
              
         
     | 
| 
      
 78 
     | 
    
         
            +
              def test_pid
         
     | 
| 
      
 79 
     | 
    
         
            +
                begin
         
     | 
| 
      
 80 
     | 
    
         
            +
                  assert_equal(@@editor_pid, @@xwin.pid)
         
     | 
| 
      
 81 
     | 
    
         
            +
                rescue NotImplementedError
         
     | 
| 
      
 82 
     | 
    
         
            +
                  notify("Your window manager or your editor doesn't support EWMH _NET_WM_PID.")
         
     | 
| 
      
 83 
     | 
    
         
            +
                end
         
     | 
| 
      
 84 
     | 
    
         
            +
              end
         
     | 
| 
      
 85 
     | 
    
         
            +
              
         
     | 
| 
      
 86 
     | 
    
         
            +
              def test_resize
         
     | 
| 
      
 87 
     | 
    
         
            +
                @@xwin.resize(500, 400)
         
     | 
| 
      
 88 
     | 
    
         
            +
                sleep 1
         
     | 
| 
      
 89 
     | 
    
         
            +
                assert_equal([500, 400], @@xwin.size)
         
     | 
| 
      
 90 
     | 
    
         
            +
              end
         
     | 
| 
      
 91 
     | 
    
         
            +
              
         
     | 
| 
      
 92 
     | 
    
         
            +
              def test_is_root_win
         
     | 
| 
      
 93 
     | 
    
         
            +
                assert(Imitator::X::XWindow.default_root_window.root_win?)
         
     | 
| 
      
 94 
     | 
    
         
            +
              end
         
     | 
| 
      
 95 
     | 
    
         
            +
              
         
     | 
| 
      
 96 
     | 
    
         
            +
              def test_is_visible
         
     | 
| 
      
 97 
     | 
    
         
            +
                assert(@@xwin.visible?)
         
     | 
| 
      
 98 
     | 
    
         
            +
                @@xwin.unmap
         
     | 
| 
      
 99 
     | 
    
         
            +
                sleep 1
         
     | 
| 
      
 100 
     | 
    
         
            +
                assert(!@@xwin.visible?)
         
     | 
| 
      
 101 
     | 
    
         
            +
                @@xwin.map
         
     | 
| 
      
 102 
     | 
    
         
            +
                sleep 1
         
     | 
| 
      
 103 
     | 
    
         
            +
                assert(@@xwin.visible?)
         
     | 
| 
      
 104 
     | 
    
         
            +
              end
         
     | 
| 
      
 105 
     | 
    
         
            +
              
         
     | 
| 
      
 106 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,123 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification 
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: imitator_x
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version 
         
     | 
| 
      
 4 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 5 
     | 
    
         
            +
              segments: 
         
     | 
| 
      
 6 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 7 
     | 
    
         
            +
              - 0
         
     | 
| 
      
 8 
     | 
    
         
            +
              - 1
         
     | 
| 
      
 9 
     | 
    
         
            +
              version: 0.0.1
         
     | 
| 
      
 10 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 11 
     | 
    
         
            +
            authors: 
         
     | 
| 
      
 12 
     | 
    
         
            +
            - "Marvin G\xC3\xBClker"
         
     | 
| 
      
 13 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 14 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 15 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            date: 2010-05-01 00:00:00 +02:00
         
     | 
| 
      
 18 
     | 
    
         
            +
            default_executable: 
         
     | 
| 
      
 19 
     | 
    
         
            +
            dependencies: 
         
     | 
| 
      
 20 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency 
         
     | 
| 
      
 21 
     | 
    
         
            +
              name: test-unit
         
     | 
| 
      
 22 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 23 
     | 
    
         
            +
              requirement: &id001 !ruby/object:Gem::Requirement 
         
     | 
| 
      
 24 
     | 
    
         
            +
                requirements: 
         
     | 
| 
      
 25 
     | 
    
         
            +
                - - ">="
         
     | 
| 
      
 26 
     | 
    
         
            +
                  - !ruby/object:Gem::Version 
         
     | 
| 
      
 27 
     | 
    
         
            +
                    segments: 
         
     | 
| 
      
 28 
     | 
    
         
            +
                    - 2
         
     | 
| 
      
 29 
     | 
    
         
            +
                    - 0
         
     | 
| 
      
 30 
     | 
    
         
            +
                    version: "2.0"
         
     | 
| 
      
 31 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 32 
     | 
    
         
            +
              version_requirements: *id001
         
     | 
| 
      
 33 
     | 
    
         
            +
            description: |
         
     | 
| 
      
 34 
     | 
    
         
            +
              The Imitator for X library allows you to simulate key and 
         
     | 
| 
      
 35 
     | 
    
         
            +
              mouse input to any Linux system that uses the X server version 11. 
         
     | 
| 
      
 36 
     | 
    
         
            +
              Features also include CD/DVD drive control and direct interaction 
         
     | 
| 
      
 37 
     | 
    
         
            +
              with Windows, wrapped as Rubyish objects. 
         
     | 
| 
      
 38 
     | 
    
         
            +
              It's a Ruby 1.9-only library. Please also note that this is 
         
     | 
| 
      
 39 
     | 
    
         
            +
              a C extension that will be compiled during installing. 
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            email: sutniuq<>gmx<>net
         
     | 
| 
      
 42 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
            extensions: 
         
     | 
| 
      
 45 
     | 
    
         
            +
            - ext/extconf.rb
         
     | 
| 
      
 46 
     | 
    
         
            +
            extra_rdoc_files: 
         
     | 
| 
      
 47 
     | 
    
         
            +
            - README.rdoc
         
     | 
| 
      
 48 
     | 
    
         
            +
            - TODO.rdoc
         
     | 
| 
      
 49 
     | 
    
         
            +
            - COPYING.rdoc
         
     | 
| 
      
 50 
     | 
    
         
            +
            - COPYING.LESSER.rdoc
         
     | 
| 
      
 51 
     | 
    
         
            +
            - ext/x.c
         
     | 
| 
      
 52 
     | 
    
         
            +
            - ext/xwindow.c
         
     | 
| 
      
 53 
     | 
    
         
            +
            - ext/mouse.c
         
     | 
| 
      
 54 
     | 
    
         
            +
            - ext/clipboard.c
         
     | 
| 
      
 55 
     | 
    
         
            +
            - ext/keyboard.c
         
     | 
| 
      
 56 
     | 
    
         
            +
            files: 
         
     | 
| 
      
 57 
     | 
    
         
            +
            - lib/imitator/x.rb
         
     | 
| 
      
 58 
     | 
    
         
            +
            - lib/imitator/x/drive.rb
         
     | 
| 
      
 59 
     | 
    
         
            +
            - ext/mouse.c
         
     | 
| 
      
 60 
     | 
    
         
            +
            - ext/keyboard.c
         
     | 
| 
      
 61 
     | 
    
         
            +
            - ext/x.c
         
     | 
| 
      
 62 
     | 
    
         
            +
            - ext/clipboard.c
         
     | 
| 
      
 63 
     | 
    
         
            +
            - ext/xwindow.c
         
     | 
| 
      
 64 
     | 
    
         
            +
            - ext/keyboard.h
         
     | 
| 
      
 65 
     | 
    
         
            +
            - ext/mouse.h
         
     | 
| 
      
 66 
     | 
    
         
            +
            - ext/x.h
         
     | 
| 
      
 67 
     | 
    
         
            +
            - ext/xwindow.h
         
     | 
| 
      
 68 
     | 
    
         
            +
            - ext/clipboard.h
         
     | 
| 
      
 69 
     | 
    
         
            +
            - test/test_xdrive.rb
         
     | 
| 
      
 70 
     | 
    
         
            +
            - test/test_mouse.rb
         
     | 
| 
      
 71 
     | 
    
         
            +
            - test/test_keyboard.rb
         
     | 
| 
      
 72 
     | 
    
         
            +
            - test/test_xwindow.rb
         
     | 
| 
      
 73 
     | 
    
         
            +
            - test/test_clipboard.rb
         
     | 
| 
      
 74 
     | 
    
         
            +
            - ext/extconf.rb
         
     | 
| 
      
 75 
     | 
    
         
            +
            - lib/imitator_x_special_chars.yml
         
     | 
| 
      
 76 
     | 
    
         
            +
            - Rakefile.rb
         
     | 
| 
      
 77 
     | 
    
         
            +
            - README.rdoc
         
     | 
| 
      
 78 
     | 
    
         
            +
            - TODO.rdoc
         
     | 
| 
      
 79 
     | 
    
         
            +
            - COPYING.rdoc
         
     | 
| 
      
 80 
     | 
    
         
            +
            - COPYING.LESSER.rdoc
         
     | 
| 
      
 81 
     | 
    
         
            +
            has_rdoc: true
         
     | 
| 
      
 82 
     | 
    
         
            +
            homepage: http://github.com/Quintus/imitator
         
     | 
| 
      
 83 
     | 
    
         
            +
            licenses: []
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 86 
     | 
    
         
            +
            rdoc_options: 
         
     | 
| 
      
 87 
     | 
    
         
            +
            - -t
         
     | 
| 
      
 88 
     | 
    
         
            +
            - "Imitator for X: RDocs"
         
     | 
| 
      
 89 
     | 
    
         
            +
            - -m
         
     | 
| 
      
 90 
     | 
    
         
            +
            - README.rdoc
         
     | 
| 
      
 91 
     | 
    
         
            +
            - -c
         
     | 
| 
      
 92 
     | 
    
         
            +
            - ISO-8859-1
         
     | 
| 
      
 93 
     | 
    
         
            +
            require_paths: 
         
     | 
| 
      
 94 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 95 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 96 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 97 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 98 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 99 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 100 
     | 
    
         
            +
                  - 1
         
     | 
| 
      
 101 
     | 
    
         
            +
                  - 9
         
     | 
| 
      
 102 
     | 
    
         
            +
                  version: "1.9"
         
     | 
| 
      
 103 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
      
 104 
     | 
    
         
            +
              requirements: 
         
     | 
| 
      
 105 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 106 
     | 
    
         
            +
                - !ruby/object:Gem::Version 
         
     | 
| 
      
 107 
     | 
    
         
            +
                  segments: 
         
     | 
| 
      
 108 
     | 
    
         
            +
                  - 0
         
     | 
| 
      
 109 
     | 
    
         
            +
                  version: "0"
         
     | 
| 
      
 110 
     | 
    
         
            +
            requirements: 
         
     | 
| 
      
 111 
     | 
    
         
            +
            - Linux with X11
         
     | 
| 
      
 112 
     | 
    
         
            +
            - eject command (usually installed)
         
     | 
| 
      
 113 
     | 
    
         
            +
            rubyforge_project: 
         
     | 
| 
      
 114 
     | 
    
         
            +
            rubygems_version: 1.3.6
         
     | 
| 
      
 115 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 116 
     | 
    
         
            +
            specification_version: 3
         
     | 
| 
      
 117 
     | 
    
         
            +
            summary: Simulate keyboard and mouse input directly via Ruby to a Linux X server system
         
     | 
| 
      
 118 
     | 
    
         
            +
            test_files: 
         
     | 
| 
      
 119 
     | 
    
         
            +
            - test/test_xdrive.rb
         
     | 
| 
      
 120 
     | 
    
         
            +
            - test/test_mouse.rb
         
     | 
| 
      
 121 
     | 
    
         
            +
            - test/test_keyboard.rb
         
     | 
| 
      
 122 
     | 
    
         
            +
            - test/test_xwindow.rb
         
     | 
| 
      
 123 
     | 
    
         
            +
            - test/test_clipboard.rb
         
     |