x11 0.0.1a1 → 0.0.1a2

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 (52) hide show
  1. data/lib/X11/X.rb +3 -0
  2. data/lib/X11/X/c.rb +16 -15
  3. data/lib/X11/Xatom.rb +167 -0
  4. data/lib/X11/Xatom/c.rb +52 -0
  5. data/lib/X11/Xdefs/c.rb +10 -6
  6. data/lib/X11/Xlib.rb +6 -0
  7. data/lib/X11/Xlib/c/functions.rb +15 -0
  8. data/lib/X11/Xlib/c/type/key_sym.rb +47 -0
  9. data/lib/X11/Xlib/c/type/status.rb +47 -0
  10. data/lib/X11/Xlib/c/types.rb +2 -0
  11. data/lib/X11/Xlib/display.rb +128 -28
  12. data/lib/X11/Xlib/event.rb +15 -0
  13. data/lib/X11/Xlib/event/generic_event.rb +1 -1
  14. data/lib/X11/Xlib/event/helper.rb +19 -13
  15. data/lib/X11/Xlib/exceptions.rb +37 -0
  16. data/lib/X11/Xlib/hints.rb +49 -0
  17. data/lib/X11/Xlib/hints/flags.rb +42 -0
  18. data/lib/X11/Xlib/hints/icon.rb +44 -0
  19. data/lib/X11/Xlib/keysym.rb +53 -0
  20. data/lib/X11/Xlib/mask.rb +52 -40
  21. data/lib/X11/Xlib/revert_to.rb +37 -0
  22. data/lib/X11/Xlib/screen.rb +12 -1
  23. data/lib/X11/Xlib/status.rb +93 -0
  24. data/lib/X11/Xlib/transform.rb +58 -0
  25. data/lib/X11/Xlib/window.rb +164 -51
  26. data/lib/X11/Xlib/window/properties.rb +66 -0
  27. data/lib/X11/Xlib/window/properties/property.rb +98 -0
  28. data/lib/X11/Xlib/window/properties/property/class.rb +37 -0
  29. data/lib/X11/Xlib/window/properties/property/command.rb +37 -0
  30. data/lib/X11/Xlib/window/properties/property/net_virtual_root.rb +39 -0
  31. data/lib/X11/Xlib/window/properties/property/parser.rb +69 -0
  32. data/lib/X11/Xlib/window/properties/property/parser/arc.rb +41 -0
  33. data/lib/X11/Xlib/window/properties/property/parser/atom.rb +35 -0
  34. data/lib/X11/Xlib/window/properties/property/parser/cardinal.rb +34 -0
  35. data/lib/X11/Xlib/window/properties/property/parser/hints.rb +41 -0
  36. data/lib/X11/Xmd/c.rb +14 -12
  37. data/lib/X11/Xutil.rb +41 -0
  38. data/lib/X11/Xutil/c.rb +33 -0
  39. data/lib/X11/Xutil/c/functions.rb +37 -0
  40. data/lib/X11/Xutil/c/type/class_hint.rb +33 -0
  41. data/lib/X11/Xutil/c/type/text_property.rb +35 -0
  42. data/lib/X11/Xutil/c/types.rb +30 -0
  43. data/lib/X11/Xutil/window.rb +61 -0
  44. data/lib/X11/cursorfont.rb +31 -0
  45. data/lib/X11/cursorfont/c.rb +41 -0
  46. data/lib/X11/cursorfont/font.rb +147 -0
  47. data/lib/X11/extensions.rb +81 -16
  48. data/lib/X11/keysym.rb +47 -0
  49. data/lib/X11/simple.rb +33 -0
  50. data/lib/X11/simple/display.rb +64 -0
  51. data/lib/X11/simple/window.rb +45 -0
  52. metadata +63 -5
@@ -0,0 +1,41 @@
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; class Properties; class Property
30
+
31
+ Parser.register :WM_HINTS do |property, data|
32
+ data = Parser.format(property, data, 'ibciiiiii')
33
+
34
+ X11::Hints.new(
35
+ Mask::Hint[data.shift], data.shift, Mask::State[data.shift],
36
+ X11::Hints::Icon.new(*data.shift(4)), X11::Window.new(property.display, data.shift)
37
+ )
38
+ )
39
+ end
40
+
41
+ end; end; end; end
@@ -30,20 +30,22 @@ require 'X11/extensions'
30
30
 
31
31
  module X11; module C
32
32
 
33
- typedef :int8, :INT8
34
- typedef :int16, :INT16
35
- typedef :int32, :INT32
36
- typedef :int64, :INT64
33
+ module ::FFI
34
+ typedef :int8, :INT8
35
+ typedef :int16, :INT16
36
+ typedef :int32, :INT32
37
+ typedef :int64, :INT64
37
38
 
38
- typedef :uint8, :CARD8
39
- typedef :uint16, :CARD16
40
- typedef :uint32, :CARD32
41
- typedef :uint64, :CARD64
39
+ typedef :uint8, :CARD8
40
+ typedef :uint16, :CARD16
41
+ typedef :uint32, :CARD32
42
+ typedef :uint64, :CARD64
42
43
 
43
- typedef :CARD16, :BITS16
44
- typedef :CARD32, :BITS32
44
+ typedef :CARD16, :BITS16
45
+ typedef :CARD32, :BITS32
45
46
 
46
- typedef :CARD8, :BYTE
47
- typedef :CARD8, :BOOL
47
+ typedef :CARD8, :BYTE
48
+ typedef :CARD8, :BOOL
49
+ end
48
50
 
49
51
  end; end
@@ -0,0 +1,41 @@
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/Xutil/c'
30
+
31
+ require 'X11/Xutil/window'
32
+
33
+ module X11
34
+
35
+ module State
36
+ Withdrawn = 0
37
+ Normal = 1
38
+ Iconic = 3
39
+ end
40
+
41
+ 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
+ require 'X11/Xlib'
30
+ require 'X11/keysym'
31
+
32
+ require 'X11/Xutil/c/types'
33
+ require 'X11/Xutil/c/functions'
@@ -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
+ module X11; module C
30
+
31
+ attach_function :XGetClassHint, [:pointer, :Window, :pointer], :Status
32
+ attach_function :XAllocClassHint, [], :pointer
33
+
34
+ attach_function :XGetWMName, [:pointer, :Window, XTextProperty], :Status
35
+ attach_function :XFetchName, [:pointer, :Window, :pointer], :Status
36
+
37
+ end; 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::C::XClassHint < FFI::Struct
30
+ layout \
31
+ :res_name, :string,
32
+ :res_class, :string
33
+ end
@@ -0,0 +1,35 @@
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::XTextProperty < FFI::Struct
30
+ layout \
31
+ :value, :string,
32
+ :encoding, :Atom,
33
+ :format, :int,
34
+ :nitems, :ulong
35
+ end
@@ -0,0 +1,30 @@
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/Xutil/c/type/class_hint'
30
+ require 'X11/Xutil/c/type/text_property'
@@ -0,0 +1,61 @@
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 Window
32
+ def title
33
+ text = FFI::MemoryPointer.new :pointer
34
+
35
+ C::XFetchName(display.to_ffi, to_ffi, text)
36
+
37
+ return if text.typecast(:pointer).null?
38
+
39
+ text.typecast(:pointer).typecast(:string).tap {
40
+ C::XFree(text.typecast(:pointer))
41
+ }
42
+ end
43
+
44
+ def class_hint
45
+ return if (hint = C::XAllocClassHint()).null?
46
+
47
+ if C::XGetClassHint(display.to_ffi, to_ffi, hint).zero?
48
+ C::XFree(hint)
49
+
50
+ return
51
+ end
52
+
53
+ C::XClassHint.new(hint).tap {|c|
54
+ break OpenStruct.new(:name => c[:res_name], :class => c[:res_class])
55
+ }.tap {
56
+ C::XFree(hint)
57
+ }
58
+ end
59
+ end
60
+
61
+ end
@@ -0,0 +1,31 @@
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/cursorfont/c'
30
+
31
+ require 'X11/cursorfont/font'
@@ -0,0 +1,41 @@
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'
30
+
31
+ module X11; module C
32
+
33
+ ffi_lib_add 'X11'
34
+
35
+ module ::FFI
36
+ typedef :CARD32, :Cursor
37
+ end
38
+
39
+ attach_function :XCreateFontCursor, [:pointer, :uint], :Cursor
40
+
41
+ end; end
@@ -0,0 +1,147 @@
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; module Cursor
30
+
31
+ class Font
32
+ module Shapes
33
+ @shapes = {
34
+ :num_glyphs => 154,
35
+ :X_cursor => 0,
36
+ :arrow => 2,
37
+ :based_arrow_down => 4,
38
+ :based_arrow_up => 6,
39
+ :boat => 8,
40
+ :bogosity => 10,
41
+ :bottom_left_corner => 12,
42
+ :bottom_right_corner => 14,
43
+ :bottom_side => 16,
44
+ :bottom_tee => 18,
45
+ :box_spiral => 20,
46
+ :center_ptr => 22,
47
+ :circle => 24,
48
+ :clock => 26,
49
+ :coffee_mug => 28,
50
+ :cross => 30,
51
+ :cross_reverse => 32,
52
+ :crosshair => 34,
53
+ :diamond_cross => 36,
54
+ :dot => 38,
55
+ :dotbox => 40,
56
+ :double_arrow => 42,
57
+ :draft_large => 44,
58
+ :draft_small => 46,
59
+ :draped_box => 48,
60
+ :exchange => 50,
61
+ :fleur => 52,
62
+ :gobbler => 54,
63
+ :gumby => 56,
64
+ :hand1 => 58,
65
+ :hand2 => 60,
66
+ :heart => 62,
67
+ :icon => 64,
68
+ :iron_cross => 66,
69
+ :left_ptr => 68,
70
+ :left_side => 70,
71
+ :left_tee => 72,
72
+ :leftbutton => 74,
73
+ :ll_angle => 76,
74
+ :lr_angle => 78,
75
+ :man => 80,
76
+ :middlebutton => 82,
77
+ :mouse => 84,
78
+ :pencil => 86,
79
+ :pirate => 88,
80
+ :plus => 90,
81
+ :question_arrow => 92,
82
+ :right_ptr => 94,
83
+ :right_side => 96,
84
+ :right_tee => 98,
85
+ :rightbutton => 100,
86
+ :rtl_logo => 102,
87
+ :sailboat => 104,
88
+ :sb_down_arrow => 106,
89
+ :sb_h_double_arrow => 108,
90
+ :sb_left_arrow => 110,
91
+ :sb_right_arrow => 112,
92
+ :sb_up_arrow => 114,
93
+ :sb_v_double_arrow => 116,
94
+ :shuttle => 118,
95
+ :sizing => 120,
96
+ :spider => 122,
97
+ :spraycan => 124,
98
+ :star => 126,
99
+ :target => 128,
100
+ :tcross => 130,
101
+ :top_left_arrow => 132,
102
+ :top_left_corner => 134,
103
+ :top_right_corner => 136,
104
+ :top_side => 138,
105
+ :top_tee => 140,
106
+ :trek => 142,
107
+ :ul_angle => 144,
108
+ :umbrella => 146,
109
+ :ur_angle => 148,
110
+ :watch => 150,
111
+ :xterm => 152
112
+ }
113
+
114
+ def self.[] (name)
115
+ if name.is_a?(Integer)
116
+ @shapes.key(name)
117
+ else
118
+ @shapes[name.to_s.to_sym]
119
+ end
120
+ end
121
+
122
+ def self.const_missing (name)
123
+ @shapes[name]
124
+ end
125
+
126
+ def self.method_missing (name, *)
127
+ @shapes[name]
128
+ end
129
+ end
130
+
131
+ attr_reader :display
132
+
133
+ def initialize (display, shape)
134
+ @display = display
135
+ @shape = shape.is_a?(Integer) ? shape : Shapes[shape]
136
+ end
137
+
138
+ def to_s
139
+ Shapes[@shape].to_s
140
+ end
141
+
142
+ def to_ffi
143
+ C::XCreateFontCursor(display.to_ffi, @shape)
144
+ end
145
+ end
146
+
147
+ end; end