x11 0.0.1a1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. data/lib/X11/X.rb +33 -0
  2. data/lib/X11/X/c.rb +48 -0
  3. data/lib/X11/Xdefs.rb +29 -0
  4. data/lib/X11/Xdefs/c.rb +54 -0
  5. data/lib/X11/Xlib.rb +37 -0
  6. data/lib/X11/Xlib/c.rb +36 -0
  7. data/lib/X11/Xlib/c/functions.rb +54 -0
  8. data/lib/X11/Xlib/c/type/any_event.rb +36 -0
  9. data/lib/X11/Xlib/c/type/button_event.rb +46 -0
  10. data/lib/X11/Xlib/c/type/circulate_event.rb +38 -0
  11. data/lib/X11/Xlib/c/type/circulate_request_event.rb +38 -0
  12. data/lib/X11/Xlib/c/type/client_message_event.rb +46 -0
  13. data/lib/X11/Xlib/c/type/colormap_event.rb +39 -0
  14. data/lib/X11/Xlib/c/type/configure_event.rb +44 -0
  15. data/lib/X11/Xlib/c/type/configure_request_event.rb +45 -0
  16. data/lib/X11/Xlib/c/type/create_window_event.rb +43 -0
  17. data/lib/X11/Xlib/c/type/crossing_event.rb +48 -0
  18. data/lib/X11/Xlib/c/type/destroy_window_event.rb +37 -0
  19. data/lib/X11/Xlib/c/type/display.rb +75 -0
  20. data/lib/X11/Xlib/c/type/error_event.rb +38 -0
  21. data/lib/X11/Xlib/c/type/event.rb +67 -0
  22. data/lib/X11/Xlib/c/type/expose_event.rb +41 -0
  23. data/lib/X11/Xlib/c/type/focus_change_event.rb +38 -0
  24. data/lib/X11/Xlib/c/type/gc.rb +33 -0
  25. data/lib/X11/Xlib/c/type/generic_event.rb +37 -0
  26. data/lib/X11/Xlib/c/type/generic_event_cookie.rb +39 -0
  27. data/lib/X11/Xlib/c/type/graphics_expose_event.rb +44 -0
  28. data/lib/X11/Xlib/c/type/gravity_event.rb +39 -0
  29. data/lib/X11/Xlib/c/type/key_event.rb +46 -0
  30. data/lib/X11/Xlib/c/type/keymap_event.rb +37 -0
  31. data/lib/X11/Xlib/c/type/map_event.rb +38 -0
  32. data/lib/X11/Xlib/c/type/map_request_event.rb +41 -0
  33. data/lib/X11/Xlib/c/type/mapping_event.rb +39 -0
  34. data/lib/X11/Xlib/c/type/motion_event.rb +46 -0
  35. data/lib/X11/Xlib/c/type/no_expose_event.rb +38 -0
  36. data/lib/X11/Xlib/c/type/property_event.rb +39 -0
  37. data/lib/X11/Xlib/c/type/reparent_event.rb +41 -0
  38. data/lib/X11/Xlib/c/type/resize_request_event.rb +38 -0
  39. data/lib/X11/Xlib/c/type/screen.rb +50 -0
  40. data/lib/X11/Xlib/c/type/selection_clear_event.rb +38 -0
  41. data/lib/X11/Xlib/c/type/selection_event.rb +40 -0
  42. data/lib/X11/Xlib/c/type/selection_request_event.rb +41 -0
  43. data/lib/X11/Xlib/c/type/unmap_event.rb +38 -0
  44. data/lib/X11/Xlib/c/type/visibility_event.rb +37 -0
  45. data/lib/X11/Xlib/c/type/visual.rb +39 -0
  46. data/lib/X11/Xlib/c/type/window_attributes.rb +54 -0
  47. data/lib/X11/Xlib/c/types.rb +71 -0
  48. data/lib/X11/Xlib/display.rb +101 -0
  49. data/lib/X11/Xlib/event.rb +55 -0
  50. data/lib/X11/Xlib/event/any.rb +33 -0
  51. data/lib/X11/Xlib/event/button_press.rb +44 -0
  52. data/lib/X11/Xlib/event/button_release.rb +44 -0
  53. data/lib/X11/Xlib/event/circulate_notify.rb +36 -0
  54. data/lib/X11/Xlib/event/circulate_request.rb +36 -0
  55. data/lib/X11/Xlib/event/client_message.rb +37 -0
  56. data/lib/X11/Xlib/event/colormap_notify.rb +37 -0
  57. data/lib/X11/Xlib/event/configure_notify.rb +42 -0
  58. data/lib/X11/Xlib/event/configure_request.rb +43 -0
  59. data/lib/X11/Xlib/event/create_notify.rb +41 -0
  60. data/lib/X11/Xlib/event/destroy_notify.rb +35 -0
  61. data/lib/X11/Xlib/event/enter_notify.rb +31 -0
  62. data/lib/X11/Xlib/event/expose.rb +39 -0
  63. data/lib/X11/Xlib/event/focus_in.rb +36 -0
  64. data/lib/X11/Xlib/event/focus_out.rb +36 -0
  65. data/lib/X11/Xlib/event/generic_event.rb +38 -0
  66. data/lib/X11/Xlib/event/graphics_expose.rb +38 -0
  67. data/lib/X11/Xlib/event/gravity_notify.rb +37 -0
  68. data/lib/X11/Xlib/event/helper.rb +117 -0
  69. data/lib/X11/Xlib/event/key_press.rb +44 -0
  70. data/lib/X11/Xlib/event/key_release.rb +45 -0
  71. data/lib/X11/Xlib/event/keymap_notify.rb +39 -0
  72. data/lib/X11/Xlib/event/leave_notify.rb +43 -0
  73. data/lib/X11/Xlib/event/map_notify.rb +36 -0
  74. data/lib/X11/Xlib/event/map_request.rb +35 -0
  75. data/lib/X11/Xlib/event/mapping_notify.rb +37 -0
  76. data/lib/X11/Xlib/event/motion_notify.rb +44 -0
  77. data/lib/X11/Xlib/event/no_expose.rb +24 -0
  78. data/lib/X11/Xlib/event/property_notify.rb +37 -0
  79. data/lib/X11/Xlib/event/reparent_notify.rb +39 -0
  80. data/lib/X11/Xlib/event/resize_request.rb +36 -0
  81. data/lib/X11/Xlib/event/selection_clear.rb +36 -0
  82. data/lib/X11/Xlib/event/selection_notify.rb +39 -0
  83. data/lib/X11/Xlib/event/selection_request.rb +40 -0
  84. data/lib/X11/Xlib/event/unmap_notify.rb +36 -0
  85. data/lib/X11/Xlib/event/visibility_notify.rb +35 -0
  86. data/lib/X11/Xlib/events.rb +65 -0
  87. data/lib/X11/Xlib/mask.rb +72 -0
  88. data/lib/X11/Xlib/screen.rb +54 -0
  89. data/lib/X11/Xlib/visual.rb +48 -0
  90. data/lib/X11/Xlib/window.rb +104 -0
  91. data/lib/X11/Xlib/window/attributes.rb +67 -0
  92. data/lib/X11/Xmd.rb +29 -0
  93. data/lib/X11/Xmd/c.rb +49 -0
  94. data/lib/X11/extensions.rb +83 -0
  95. metadata +179 -0
@@ -0,0 +1,37 @@
1
+ #--
2
+ # Copyleft meh. [http://meh.paranoid.pk | meh@paranoici.org]
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without modification, are
5
+ # permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of source code must retain the above copyright notice, this list of
8
+ # conditions and the following disclaimer.
9
+ #
10
+ # 2. Redistributions in binary form must reproduce the above copyright notice, this list
11
+ # of conditions and the following disclaimer in the documentation and/or other materials
12
+ # provided with the distribution.
13
+ #
14
+ # THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY EXPRESS OR IMPLIED
15
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16
+ # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
17
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20
+ # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ #
24
+ # The views and conclusions contained in the software and documentation are those of the
25
+ # authors and should not be interpreted as representing official policies, either expressed
26
+ # or implied.
27
+ #++
28
+
29
+ class X11::C::XVisibilityEvent < FFI::Struct
30
+ layout \
31
+ :type, :int,
32
+ :serial, :ulong,
33
+ :send_event, :Bool,
34
+ :display, :pointer,
35
+ :window, :Window,
36
+ :state, :int
37
+ end
@@ -0,0 +1,39 @@
1
+ #--
2
+ # Copyleft meh. [http://meh.paranoid.pk | meh@paranoici.org]
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without modification, are
5
+ # permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of source code must retain the above copyright notice, this list of
8
+ # conditions and the following disclaimer.
9
+ #
10
+ # 2. Redistributions in binary form must reproduce the above copyright notice, this list
11
+ # of conditions and the following disclaimer in the documentation and/or other materials
12
+ # provided with the distribution.
13
+ #
14
+ # THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY EXPRESS OR IMPLIED
15
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16
+ # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
17
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20
+ # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ #
24
+ # The views and conclusions contained in the software and documentation are those of the
25
+ # authors and should not be interpreted as representing official policies, either expressed
26
+ # or implied.
27
+ #++
28
+
29
+ class X11::C::Visual < FFI::Struct
30
+ layout \
31
+ :ext_data, :pointer,
32
+ :visualid, :VisualID,
33
+ :class, :int,
34
+ :read_mask, :ulong,
35
+ :green_mask, :ulong,
36
+ :blue_mask, :ulong,
37
+ :buts_per_rgb, :int,
38
+ :map_entries, :int
39
+ end
@@ -0,0 +1,54 @@
1
+ #--
2
+ # Copyleft meh. [http://meh.paranoid.pk | meh@paranoici.org]
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without modification, are
5
+ # permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of source code must retain the above copyright notice, this list of
8
+ # conditions and the following disclaimer.
9
+ #
10
+ # 2. Redistributions in binary form must reproduce the above copyright notice, this list
11
+ # of conditions and the following disclaimer in the documentation and/or other materials
12
+ # provided with the distribution.
13
+ #
14
+ # THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY EXPRESS OR IMPLIED
15
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16
+ # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
17
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20
+ # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ #
24
+ # The views and conclusions contained in the software and documentation are those of the
25
+ # authors and should not be interpreted as representing official policies, either expressed
26
+ # or implied.
27
+ #++
28
+
29
+ class X11::C::XWindowAttributes < FFI::Struct
30
+ layout \
31
+ :x, :int,
32
+ :y, :int,
33
+ :width, :int,
34
+ :height, :int,
35
+ :border_width, :int,
36
+ :depth, :int,
37
+ :visual, :pointer,
38
+ :root, :Window,
39
+ :class, :int,
40
+ :bit_gravity, :int,
41
+ :win_gravity, :int,
42
+ :backing_store, :int,
43
+ :backing_planes, :ulong,
44
+ :backing_pixel, :ulong,
45
+ :save_under, :Bool,
46
+ :colormap, :Colormap,
47
+ :map_installed, :Bool,
48
+ :map_state, :int,
49
+ :all_event_masks, :long,
50
+ :your_event_masks, :long,
51
+ :do_not_propagate_mask, :long,
52
+ :override_redirect, :Bool,
53
+ :screen, :pointer
54
+ end
@@ -0,0 +1,71 @@
1
+ #--
2
+ # Copyleft meh. [http://meh.paranoid.pk | meh@paranoici.org]
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without modification, are
5
+ # permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of source code must retain the above copyright notice, this list of
8
+ # conditions and the following disclaimer.
9
+ #
10
+ # 2. Redistributions in binary form must reproduce the above copyright notice, this list
11
+ # of conditions and the following disclaimer in the documentation and/or other materials
12
+ # provided with the distribution.
13
+ #
14
+ # THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY EXPRESS OR IMPLIED
15
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16
+ # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
17
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20
+ # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ #
24
+ # The views and conclusions contained in the software and documentation are those of the
25
+ # authors and should not be interpreted as representing official policies, either expressed
26
+ # or implied.
27
+ #++
28
+
29
+ require 'X11/X'
30
+ require 'X11/Xdefs'
31
+
32
+ require 'X11/Xlib/c/type/display'
33
+ require 'X11/Xlib/c/type/gc'
34
+ require 'X11/Xlib/c/type/screen'
35
+ require 'X11/Xlib/c/type/window_attributes'
36
+ require 'X11/Xlib/c/type/visual'
37
+
38
+ require 'X11/Xlib/c/type/any_event'
39
+ require 'X11/Xlib/c/type/key_event'
40
+ require 'X11/Xlib/c/type/button_event'
41
+ require 'X11/Xlib/c/type/motion_event'
42
+ require 'X11/Xlib/c/type/crossing_event'
43
+ require 'X11/Xlib/c/type/focus_change_event'
44
+ require 'X11/Xlib/c/type/expose_event'
45
+ require 'X11/Xlib/c/type/graphics_expose_event'
46
+ require 'X11/Xlib/c/type/no_expose_event'
47
+ require 'X11/Xlib/c/type/visibility_event'
48
+ require 'X11/Xlib/c/type/create_window_event'
49
+ require 'X11/Xlib/c/type/destroy_window_event'
50
+ require 'X11/Xlib/c/type/unmap_event'
51
+ require 'X11/Xlib/c/type/map_event'
52
+ require 'X11/Xlib/c/type/map_request_event'
53
+ require 'X11/Xlib/c/type/reparent_event'
54
+ require 'X11/Xlib/c/type/configure_event'
55
+ require 'X11/Xlib/c/type/gravity_event'
56
+ require 'X11/Xlib/c/type/resize_request_event'
57
+ require 'X11/Xlib/c/type/configure_request_event'
58
+ require 'X11/Xlib/c/type/circulate_event'
59
+ require 'X11/Xlib/c/type/circulate_request_event'
60
+ require 'X11/Xlib/c/type/property_event'
61
+ require 'X11/Xlib/c/type/selection_clear_event'
62
+ require 'X11/Xlib/c/type/selection_request_event'
63
+ require 'X11/Xlib/c/type/selection_event'
64
+ require 'X11/Xlib/c/type/colormap_event'
65
+ require 'X11/Xlib/c/type/client_message_event'
66
+ require 'X11/Xlib/c/type/mapping_event'
67
+ require 'X11/Xlib/c/type/error_event'
68
+ require 'X11/Xlib/c/type/keymap_event'
69
+ require 'X11/Xlib/c/type/generic_event'
70
+ require 'X11/Xlib/c/type/generic_event_cookie'
71
+ require 'X11/Xlib/c/type/event'
@@ -0,0 +1,101 @@
1
+ #--
2
+ # Copyleft meh. [http://meh.paranoid.pk | meh@paranoici.org]
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without modification, are
5
+ # permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of source code must retain the above copyright notice, this list of
8
+ # conditions and the following disclaimer.
9
+ #
10
+ # 2. Redistributions in binary form must reproduce the above copyright notice, this list
11
+ # of conditions and the following disclaimer in the documentation and/or other materials
12
+ # provided with the distribution.
13
+ #
14
+ # THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY EXPRESS OR IMPLIED
15
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16
+ # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
17
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20
+ # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ #
24
+ # The views and conclusions contained in the software and documentation are those of the
25
+ # authors and should not be interpreted as representing official policies, either expressed
26
+ # or implied.
27
+ #++
28
+
29
+ module X11
30
+
31
+ class Display
32
+ def initialize (name=nil)
33
+ pointer = (name.is_a?(String) or !name) ? X11::C::XOpenDisplay(name) : name
34
+ @display = pointer.is_a?(C::Display) ? pointer : pointer.typecast(C::Display)
35
+ end
36
+
37
+ def ungrab_pointer (time=0)
38
+ C::XUngrabPointer(to_c, time)
39
+ end
40
+
41
+ def keysym_to_keycode (keysym)
42
+ C::XKeysymToKeycode(to_c, keysym)
43
+ end
44
+
45
+ def check_typed_event (event)
46
+ event = Event.index(event)
47
+ ev = FFI::MemoryPointer.new(C::XEvent)
48
+
49
+ C::XCheckTypedEvent(to_c, event, ev) or return
50
+
51
+ Event.new(ev)
52
+ end
53
+
54
+ def screen (which)
55
+ Screen.new(self, @display[:screens] + (which * C::Screen.size))
56
+ end
57
+
58
+ def default_screen
59
+ screen(@display[:default_screen])
60
+ end
61
+
62
+ def screens
63
+ (0 ... @display[:nscreens]).map {|i|
64
+ screen(i)
65
+ }
66
+ end
67
+
68
+ def width (index=nil)
69
+ if index
70
+ screen(index).width
71
+ else
72
+ default_screen.width
73
+ end
74
+ end
75
+
76
+ def next_event
77
+ ev = FFI::MemoryPointer.new(C::XEvent)
78
+
79
+ C::XNextEvent(to_c, ev)
80
+
81
+ Event.new(ev)
82
+ end
83
+
84
+ def each_event
85
+ loop {
86
+ next_event.tap {|ev|
87
+ yield ev if block_given?
88
+ }
89
+ }
90
+ end
91
+
92
+ def close
93
+ C::XCloseDisplay(to_c)
94
+ end
95
+
96
+ def to_c
97
+ @display.pointer
98
+ end
99
+ end
100
+
101
+ end
@@ -0,0 +1,55 @@
1
+ #--
2
+ # Copyleft meh. [http://meh.paranoid.pk | meh@paranoici.org]
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without modification, are
5
+ # permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of source code must retain the above copyright notice, this list of
8
+ # conditions and the following disclaimer.
9
+ #
10
+ # 2. Redistributions in binary form must reproduce the above copyright notice, this list
11
+ # of conditions and the following disclaimer in the documentation and/or other materials
12
+ # provided with the distribution.
13
+ #
14
+ # THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY EXPRESS OR IMPLIED
15
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16
+ # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
17
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20
+ # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ #
24
+ # The views and conclusions contained in the software and documentation are those of the
25
+ # authors and should not be interpreted as representing official policies, either expressed
26
+ # or implied.
27
+ #++
28
+
29
+ require 'X11/Xlib/events'
30
+
31
+ module X11
32
+
33
+ class Event
34
+ def self.index (event)
35
+ Events.to_a.index(event)
36
+ end
37
+
38
+ def self.new (event)
39
+ event = event.typecast(C::XEvent) unless event.is_a?(C::XEvent)
40
+
41
+ (Events[event[:type]] || Any).new(event)
42
+ end
43
+ end
44
+
45
+ class C::XEvent
46
+ Events.to_a.compact.each {|type|
47
+ next unless type.attribute rescue nil
48
+
49
+ define_method(type.attribute) {
50
+ type.new(self)
51
+ }
52
+ }
53
+ end
54
+
55
+ end
@@ -0,0 +1,33 @@
1
+ #--
2
+ # Copyleft meh. [http://meh.paranoid.pk | meh@paranoici.org]
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without modification, are
5
+ # permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of source code must retain the above copyright notice, this list of
8
+ # conditions and the following disclaimer.
9
+ #
10
+ # 2. Redistributions in binary form must reproduce the above copyright notice, this list
11
+ # of conditions and the following disclaimer in the documentation and/or other materials
12
+ # provided with the distribution.
13
+ #
14
+ # THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY EXPRESS OR IMPLIED
15
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16
+ # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
17
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20
+ # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ #
24
+ # The views and conclusions contained in the software and documentation are those of the
25
+ # authors and should not be interpreted as representing official policies, either expressed
26
+ # or implied.
27
+ #++
28
+
29
+ class X11::Event::Any < X11::Event::Helper
30
+ attribute :xany
31
+
32
+ include X11::Event::Common
33
+ end
@@ -0,0 +1,44 @@
1
+ #--
2
+ # Copyleft meh. [http://meh.paranoid.pk | meh@paranoici.org]
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without modification, are
5
+ # permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of source code must retain the above copyright notice, this list of
8
+ # conditions and the following disclaimer.
9
+ #
10
+ # 2. Redistributions in binary form must reproduce the above copyright notice, this list
11
+ # of conditions and the following disclaimer in the documentation and/or other materials
12
+ # provided with the distribution.
13
+ #
14
+ # THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY EXPRESS OR IMPLIED
15
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16
+ # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
17
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20
+ # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ #
24
+ # The views and conclusions contained in the software and documentation are those of the
25
+ # authors and should not be interpreted as representing official policies, either expressed
26
+ # or implied.
27
+ #++
28
+
29
+ class X11::Event::ButtonPress < X11::Event::Helper
30
+ attribute :xbutton
31
+
32
+ include X11::Event::Common
33
+
34
+ manage :root, X11::Event::Window
35
+ manage :subwindow, X11::Event::Window
36
+ manage :time
37
+ manage :x
38
+ manage :y
39
+ manage :x_root
40
+ manage :y_root
41
+ manage :state
42
+ manage :button
43
+ manage [:same_screen, :same_screen?]
44
+ end
@@ -0,0 +1,44 @@
1
+ #--
2
+ # Copyleft meh. [http://meh.paranoid.pk | meh@paranoici.org]
3
+ #
4
+ # Redistribution and use in source and binary forms, with or without modification, are
5
+ # permitted provided that the following conditions are met:
6
+ #
7
+ # 1. Redistributions of source code must retain the above copyright notice, this list of
8
+ # conditions and the following disclaimer.
9
+ #
10
+ # 2. Redistributions in binary form must reproduce the above copyright notice, this list
11
+ # of conditions and the following disclaimer in the documentation and/or other materials
12
+ # provided with the distribution.
13
+ #
14
+ # THIS SOFTWARE IS PROVIDED BY <COPYRIGHT HOLDER> ''AS IS'' AND ANY EXPRESS OR IMPLIED
15
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
16
+ # FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> OR
17
+ # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19
+ # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
20
+ # ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
21
+ # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
22
+ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
+ #
24
+ # The views and conclusions contained in the software and documentation are those of the
25
+ # authors and should not be interpreted as representing official policies, either expressed
26
+ # or implied.
27
+ #++
28
+
29
+ class X11::Event::ButtonRelease < X11::Event::Helper
30
+ attribute :xbutton
31
+
32
+ include X11::Event::Common
33
+
34
+ manage :root, X11::Event::Window
35
+ manage :subwindow, X11::Event::Window
36
+ manage :time
37
+ manage :x
38
+ manage :y
39
+ manage :x_root
40
+ manage :y_root
41
+ manage :state
42
+ manage :button
43
+ manage [:same_screen, :same_screen?]
44
+ end