rumouse 0.0.5 → 0.0.6

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: f9f7eb62e0046ce75aea394340162ccfd2a67aa0
4
- data.tar.gz: 42d8f647a1a99efd4347e4da80dfcb57edb58145
3
+ metadata.gz: 05102ba45be66f59608d4fd5a6a4c5a37ef303d3
4
+ data.tar.gz: b74996fb320d5c9275c4c0affc1d194b647e119d
5
5
  SHA512:
6
- metadata.gz: 2b1722015244da55f41178c5a506fedbc2d3efe4fac39cb97c15a407e81ecd7e23f427d5ddfc2aa95cda698e5f739b3366e872e181d57804ea1af52686f1ad17
7
- data.tar.gz: 53eaa162f7c842553eac77e48e0ef9cd51b0136ce8c24912abb31cd6a420a81c38d24ba361acae740acb30c9c39a03c8556c28bbd3cb0172f1150c045a9576f6
6
+ metadata.gz: ac101ee086ad6b80f95caa1e7393c9d098e50d69908e0a69a6abaa7445d9786656dbacf8e8bfbd65761b005ecbabd941da1d1be0d6e5dc088caaa462e3954e6c
7
+ data.tar.gz: c0983a3a0b7534b051a38c202fec3465eb2d887a2fa79a5b66c5716af9c9c891a8d98ae3c73063fcdc625bce1d180e7f7cff20ada4a799999450249eb4354971
@@ -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
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
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.6
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: []
@@ -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
data/lib/x11.rb DELETED
File without changes