x11 0.0.1a1

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.
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,65 @@
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
+ X11::Events = []
30
+
31
+ require 'X11/Xlib/event/helper'
32
+
33
+ require 'X11/Xlib/event/any'
34
+ require 'X11/Xlib/event/key_press'
35
+ require 'X11/Xlib/event/key_release'
36
+ require 'X11/Xlib/event/button_press'
37
+ require 'X11/Xlib/event/button_release'
38
+ require 'X11/Xlib/event/motion_notify'
39
+ require 'X11/Xlib/event/enter_notify'
40
+ require 'X11/Xlib/event/leave_notify'
41
+ require 'X11/Xlib/event/focus_in'
42
+ require 'X11/Xlib/event/focus_out'
43
+ require 'X11/Xlib/event/keymap_notify'
44
+ require 'X11/Xlib/event/expose'
45
+ require 'X11/Xlib/event/graphics_expose'
46
+ require 'X11/Xlib/event/no_expose'
47
+ require 'X11/Xlib/event/visibility_notify'
48
+ require 'X11/Xlib/event/create_notify'
49
+ require 'X11/Xlib/event/destroy_notify'
50
+ require 'X11/Xlib/event/unmap_notify'
51
+ require 'X11/Xlib/event/map_notify'
52
+ require 'X11/Xlib/event/map_request'
53
+ require 'X11/Xlib/event/reparent_notify'
54
+ require 'X11/Xlib/event/configure_notify'
55
+ require 'X11/Xlib/event/resize_request'
56
+ require 'X11/Xlib/event/circulate_notify'
57
+ require 'X11/Xlib/event/circulate_request'
58
+ require 'X11/Xlib/event/property_notify'
59
+ require 'X11/Xlib/event/selection_clear'
60
+ require 'X11/Xlib/event/selection_request'
61
+ require 'X11/Xlib/event/selection_notify'
62
+ require 'X11/Xlib/event/colormap_notify'
63
+ require 'X11/Xlib/event/client_message'
64
+ require 'X11/Xlib/event/mapping_notify'
65
+ require 'X11/Xlib/event/generic_event'
@@ -0,0 +1,72 @@
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
+ Mask = Class.new(Hash) {
32
+ def [] (what)
33
+ super || super(what.to_s.to_sym)
34
+ end
35
+ }.new.merge(
36
+ NoEvent: 0,
37
+ KeyPress: 1,
38
+ KeyRelease: (1 << 1),
39
+ ButtonPress: (1 << 2),
40
+ ButtonRelease: (1 << 3),
41
+ EnterWindow: (1 << 4),
42
+ LeaveWindow: (1 << 5),
43
+ PointerMotion: (1 << 6),
44
+ PointerMotionHint: (1 << 7),
45
+ Button1Motion: (1 << 8),
46
+ Button2Motion: (1 << 9),
47
+ Button3Motion: (1 << 10),
48
+ Button4Motion: (1 << 11),
49
+ Button5Motion: (1 << 12),
50
+ ButtonMotion: (1 << 13),
51
+ KeymapState: (1 << 14),
52
+ Exposure: (1 << 15),
53
+ VisibilityChange: (1 << 16),
54
+ StructureNotify: (1 << 17),
55
+ ResizeRedirect: (1 << 18),
56
+ SubstructureNotify: (1 << 19),
57
+ SubstructureRedirect: (1 << 20),
58
+ FocusChange: (1 << 21),
59
+ PropertyChange: (1 << 22),
60
+ ColormapChange: (1 << 23),
61
+ OwnerGrabButton: (1 << 24),
62
+ Shift: 1,
63
+ Lock: (1 << 1),
64
+ Control: (1 << 2),
65
+ Mod1: (1 << 3),
66
+ Mod2: (1 << 4),
67
+ Mod3: (1 << 5),
68
+ Mod4: (1 << 6),
69
+ Mod5: (1 << 7)
70
+ ).freeze
71
+
72
+ 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
+ module X11
30
+
31
+ class Screen
32
+ attr_reader :display
33
+
34
+ def initialize (display, screen)
35
+ @display = display
36
+ @screen = screen.typecast(C::Screen)
37
+ end
38
+
39
+ C::Screen.layout.members.each_with_index {|name, index|
40
+ define_method name do
41
+ @screen[name]
42
+ end
43
+ }
44
+
45
+ def root_window
46
+ Window.new(@display, @screen[:root])
47
+ end
48
+
49
+ def to_c
50
+ @screen.pointer
51
+ end
52
+ end
53
+
54
+ end
@@ -0,0 +1,48 @@
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 Visual
32
+ def initialize (visual)
33
+ visual = visual.typecast(C::Visual) unless visual.is_a?(C::Visual)
34
+ @visual = visual
35
+ end
36
+
37
+ C::Visual.layout.members.each_with_index {|name, index|
38
+ define_method name do
39
+ @visual[name]
40
+ end
41
+ }
42
+
43
+ def visual_id
44
+ @visual[:VisualID]
45
+ end
46
+ end
47
+
48
+ end
@@ -0,0 +1,104 @@
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/window/attributes'
30
+
31
+ module X11
32
+ class Window
33
+
34
+ GRAB_MODE = {sync: false, async: true}
35
+
36
+ def initialize (dpy, window)
37
+ @dpy = dpy
38
+ @win = window
39
+ end
40
+
41
+ def nil?
42
+ @win.zero?
43
+ end
44
+
45
+ def attributes
46
+ attr = FFI::MemoryPointer.new(C::XWindowAttributes)
47
+ C.XGetWindowAttributes(@dpy.to_c, @win, attr)
48
+ Attributes.new(attr)
49
+ end
50
+ alias attr attributes
51
+
52
+ def grab_pointer (owner_events=true, event_mask=0, pointer_mode=:async,
53
+ keyboard_mode=:async, confine_to=0, cursor=0, time=0)
54
+ C.XGrabPointer(@dpy.to_c, @win, !!owner_events, event_mask, mode2int(pointer_mode),
55
+ mode2int(keyboard_mode), confine_to.to_c, cursor, time)
56
+ end
57
+
58
+ def ungrab_pointer (time=0)
59
+ @dpy.ungrab_pointer(time)
60
+ end
61
+
62
+ def keysym_to_keycode (keysym)
63
+ C.XKeysymToKeycode(to_c, keysym)
64
+ end
65
+
66
+ def move_resize (x, y, width, height)
67
+ C.XMoveResizeWindow(@dpy.to_c, @win, x, y, width, height)
68
+ end
69
+
70
+ def raise
71
+ C.XRaiseWindow(@dpy.to_c, @win)
72
+ end
73
+
74
+ def grab_key (keycode, modifiers=0, owner_events=true, pointer_mode=:async, keyboard_mode=:async)
75
+ C.XGrabKey(@dpy.to_c, keycode.to_keycode, modifiers, @win, !!owner_events,
76
+ mode2int(pointer_mode), mode2int(keyboard_mode))
77
+ end
78
+
79
+ def ungrab_key (keycode, modifiers=0)
80
+ C.XUngrabKey(@dpy.to_c, keycode.to_keycode, modifiers, @win)
81
+ end
82
+
83
+ def grab_button (button, modifiers=0, owner_events=true, event_mask=4,
84
+ pointer_mode=:async, keyboard_mode=:async, confine_to=0, cursor=0)
85
+ C.XGrabButton(@dpy.to_c, button, modifiers, @win, !!owner_events, event_mask,
86
+ mode2int(pointer_mode), mode2int(keyboard_mode), confine_to.to_c, cursor.to_c)
87
+ end
88
+
89
+ def ungrab_button (button, modifiers=0)
90
+ C.XUngrabButton(@dpy.to_c, button, modifiers, @win)
91
+ end
92
+
93
+ def to_c
94
+ @win
95
+ end
96
+
97
+ private
98
+ def mode2int (mode)
99
+ (mode == true or GRAB_MODE[mode]) ? 1 : 0
100
+ end
101
+ end
102
+
103
+
104
+ end
@@ -0,0 +1,67 @@
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; class Window
30
+
31
+ class Attributes
32
+ def initialize (attributes)
33
+ @attributes = attributes.is_a?(C::XWindowAttributes) ? attributes : attributes.typecast(C::XWindowAttributes)
34
+ end
35
+
36
+ C::XWindowAttributes.layout.members.each_with_index {|name, index|
37
+ define_method name do
38
+ @attributes[name]
39
+ end
40
+ }
41
+
42
+ def override_redirect?
43
+ @attributes[:override_redirect]
44
+ end
45
+
46
+ def save_under?
47
+ @attributes[:save_under]
48
+ end
49
+
50
+ def map_installed?
51
+ @attributes[:map_installed]
52
+ end
53
+
54
+ def root
55
+ Window.new(@attributes[:root])
56
+ end
57
+
58
+ def visual
59
+ Visual.new(@attributes[:visual])
60
+ end
61
+
62
+ def screen
63
+ Screen.new(@attributes[:screen])
64
+ end
65
+ end
66
+
67
+ end; end
@@ -0,0 +1,29 @@
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/Xmd/c'
@@ -0,0 +1,49 @@
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/extensions'
30
+
31
+ module X11; module C
32
+
33
+ typedef :int8, :INT8
34
+ typedef :int16, :INT16
35
+ typedef :int32, :INT32
36
+ typedef :int64, :INT64
37
+
38
+ typedef :uint8, :CARD8
39
+ typedef :uint16, :CARD16
40
+ typedef :uint32, :CARD32
41
+ typedef :uint64, :CARD64
42
+
43
+ typedef :CARD16, :BITS16
44
+ typedef :CARD32, :BITS32
45
+
46
+ typedef :CARD8, :BYTE
47
+ typedef :CARD8, :BOOL
48
+
49
+ end; end