rumouse 0.0.5 → 0.0.7

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
- SHA1:
3
- metadata.gz: f9f7eb62e0046ce75aea394340162ccfd2a67aa0
4
- data.tar.gz: 42d8f647a1a99efd4347e4da80dfcb57edb58145
2
+ SHA256:
3
+ metadata.gz: f0b0f11cb263163cbfd021ab7daad5f4161cdd6b6f8daba38fbcb4054117bcbf
4
+ data.tar.gz: f4fc5bc42d541ea1e3666f6f6d55d529ed3f4d215f2b49971e8acb174c559f83
5
5
  SHA512:
6
- metadata.gz: 2b1722015244da55f41178c5a506fedbc2d3efe4fac39cb97c15a407e81ecd7e23f427d5ddfc2aa95cda698e5f739b3366e872e181d57804ea1af52686f1ad17
7
- data.tar.gz: 53eaa162f7c842553eac77e48e0ef9cd51b0136ce8c24912abb31cd6a420a81c38d24ba361acae740acb30c9c39a03c8556c28bbd3cb0172f1150c045a9576f6
6
+ metadata.gz: 80df9e582d82a03048de90eb3705aba4afe331b5b0b0be4538065f4baf60ac3eb9d4590b8221af8b8246b7517c3e0e7285647c3011444f7b48ee390aaf7d51f5
7
+ data.tar.gz: c87ee60c6f615e94ccb47870ecd949d7b15f337be1fdbced7b210c6d6097149b9bfc176ebc8d116c170febffe500ba1d2c89c5bce4a81866218e5f15300f417b
File without changes
File without changes
@@ -0,0 +1,89 @@
1
+ require 'ffi'
2
+
3
+ module X11
4
+ extend FFI::Library
5
+ ffi_lib 'X11'
6
+ attach_function :XOpenDisplay, [ :char ], :pointer
7
+ attach_function :XWarpPointer, [ :pointer, :ulong, :ulong, :int, :int, :uint, :uint, :int, :int ], :int
8
+ attach_function :XFlush, [:pointer], :int
9
+ attach_function :XCloseDisplay, [:pointer], :int
10
+ attach_function :XDefaultRootWindow, [ :pointer ], :ulong
11
+ attach_function :XQueryPointer, [:pointer, :ulong, :pointer, :pointer, :pointer, :pointer, :pointer, :pointer, :pointer], :bool
12
+ attach_function :XWidthOfScreen, [:pointer], :int
13
+ attach_function :XHeightOfScreen, [:pointer], :int
14
+ attach_function :XDefaultScreenOfDisplay, [:pointer], :pointer
15
+ end
16
+
17
+ module Xtst
18
+ extend FFI::Library
19
+ ffi_lib 'Xtst'
20
+ attach_function :XTestFakeButtonEvent, [:pointer, :uint, :bool, :int], :int
21
+ end
22
+
23
+
24
+ class RuMouse
25
+ def press x, y, button = 1
26
+ display = X11.XOpenDisplay(0)
27
+ root = X11.XDefaultRootWindow(display)
28
+
29
+ move x,y
30
+ Xtst::XTestFakeButtonEvent(display, button, true, 0)
31
+
32
+ X11.XFlush(display)
33
+ X11.XCloseDisplay(display)
34
+ end
35
+
36
+ def release x, y, button = 1
37
+ display = X11.XOpenDisplay(0)
38
+ root = X11.XDefaultRootWindow(display)
39
+
40
+ move x,y
41
+ Xtst::XTestFakeButtonEvent(display, button, false, 0)
42
+
43
+ X11.XFlush(display)
44
+ X11.XCloseDisplay(display)
45
+ end
46
+
47
+ def click x, y, button = 1, n = 1
48
+ n.times do
49
+ press x, y, button
50
+ release x, y, button
51
+ end
52
+ end
53
+
54
+ def move x, y
55
+ display = X11.XOpenDisplay(0)
56
+ root = X11.XDefaultRootWindow(display)
57
+ X11.XWarpPointer(display, 0, root, 0, 0, 0, 0, x, y)
58
+ X11.XFlush(display)
59
+ X11.XCloseDisplay(display)
60
+ end
61
+
62
+ def position
63
+ display = X11.XOpenDisplay(0)
64
+ root = X11.XDefaultRootWindow(display)
65
+
66
+ win_root_ptr = FFI::MemoryPointer.new :pointer
67
+ win_child_ptr = FFI::MemoryPointer.new :pointer
68
+ r_x = FFI::MemoryPointer.new :pointer
69
+ r_y = FFI::MemoryPointer.new :pointer
70
+ win_x = FFI::MemoryPointer.new :pointer
71
+ win_y = FFI::MemoryPointer.new :pointer
72
+ mark_ptr = FFI::MemoryPointer.new :pointer
73
+
74
+ X11.XQueryPointer(display, root, win_root_ptr, win_child_ptr, r_x, r_y, win_x, win_y, mark_ptr)
75
+ X11.XCloseDisplay(display)
76
+
77
+ { x: win_x.read_int32, y: win_y.read_int32 }
78
+ end
79
+
80
+ def screen_size
81
+ display = X11.XOpenDisplay(0)
82
+ screen = X11.XDefaultScreenOfDisplay(display)
83
+ x = X11.XWidthOfScreen(screen)
84
+ y = X11.XHeightOfScreen(screen)
85
+ X11.XCloseDisplay(display)
86
+
87
+ {x: x, y: y}
88
+ end
89
+ end
data/lib/rumouse.rb CHANGED
@@ -33,9 +33,9 @@ os = RbConfig::CONFIG['host_os']
33
33
 
34
34
  case os
35
35
  when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
36
- require 'win32.rb'
36
+ require 'rumouse/win32.rb'
37
37
  when /darwin|mac os/
38
- require 'darwin.rb'
38
+ require 'rumouse/darwin.rb'
39
39
  when /linux|bsd/
40
- require 'x11.rb'
40
+ require 'rumouse/x11.rb'
41
41
  end
metadata CHANGED
@@ -1,10 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rumouse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxim Kostuchenko
8
+ - Eduard Antsupov
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
@@ -14,14 +15,14 @@ dependencies:
14
15
  name: ffi
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
- - - "~>"
18
+ - - ">="
18
19
  - !ruby/object:Gem::Version
19
20
  version: 1.9.3
20
21
  type: :runtime
21
22
  prerelease: false
22
23
  version_requirements: !ruby/object:Gem::Requirement
23
24
  requirements:
24
- - - "~>"
25
+ - - ">="
25
26
  - !ruby/object:Gem::Version
26
27
  version: 1.9.3
27
28
  description: Cross-platform solution for simulating mouse events
@@ -31,9 +32,9 @@ extensions: []
31
32
  extra_rdoc_files: []
32
33
  files:
33
34
  - lib/rumouse.rb
34
- - lib/darwin.rb
35
- - lib/win32.rb
36
- - lib/x11.rb
35
+ - lib/rumouse/darwin.rb
36
+ - lib/rumouse/win32.rb
37
+ - lib/rumouse/x11.rb
37
38
  homepage: https://github.com/kosmaks/rumouse
38
39
  licenses:
39
40
  - MIT
@@ -53,8 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
53
54
  - !ruby/object:Gem::Version
54
55
  version: '0'
55
56
  requirements: []
56
- rubyforge_project:
57
- rubygems_version: 2.0.3
57
+ rubygems_version: 3.0.3.1
58
58
  signing_key:
59
59
  specification_version: 4
60
60
  summary: Port of pythons' PyMouse.
data/lib/x11.rb DELETED
File without changes