rwayland 0.1.1

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.
@@ -0,0 +1,88 @@
1
+ require 'fiddle/import'
2
+
3
+ module Wayland
4
+ module XkbSupport
5
+ XKB_CONTEXT_NO_FLAGS = 0
6
+ XKB_CONTEXT_NO_DEFAULT_INCLUDES = (1 << 0)
7
+ XKB_CONTEXT_NO_ENVIRONMENT_NAMES = (1 << 1)
8
+ XKB_CONTEXT_NO_SECURE_GETENV = (1 << 2)
9
+ XKB_KEYMAP_FORMAT_TEXT_V1 = 1
10
+ XKB_KEYMAP_COMPILE_NO_FLAGS = 0
11
+ module F
12
+ extend Fiddle::Importer
13
+ dlload "libxkbcommon.so.0"
14
+ extern "void *xkb_context_new(int)"
15
+ extern "void *xkb_context_ref(void *)"
16
+ extern "void xkb_context_unref(void *)"
17
+ extern "void xkb_context_set_user_data(void *, void *)"
18
+ extern "void *xkb_context_get_user_data(void *)"
19
+
20
+ extern "void *xkb_keymap_new_from_string(void *, void *, int, int)"
21
+ extern "void *xkb_keymap_ref(void *)"
22
+ extern "void xkb_keymap_unref(void *)"
23
+
24
+ extern "void *xkb_state_new(void *)"
25
+ extern "void *xkb_state_ref(void *)"
26
+ extern "void xkb_state_unref(void *)"
27
+ extern "unsigned int xkb_state_key_get_one_sym(void *, unsigned int)"
28
+ extern "int xkb_state_key_get_utf8(void *, int, void *, size_t)"
29
+ extern "unsigned int xkb_state_update_mask(void *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)"
30
+ end
31
+ end
32
+
33
+ module Xkb
34
+ class Context
35
+ def initialize(flags = XkbSupport::XKB_CONTEXT_NO_FLAGS)
36
+ @pointer = XkbSupport::F.xkb_context_new flags
37
+ @pointer.free = XkbSupport::F[:xkb_context_unref]
38
+ end
39
+
40
+ def keymap_new_from_string(source, format, flags)
41
+ ptr = XkbSupport::F.xkb_keymap_new_from_string(@pointer, source, format, flags)
42
+ ptr.free = XkbSupport::F[:xkb_keymap_unref]
43
+ obj = Keymap.new
44
+ obj.instance_eval do
45
+ @context = self
46
+ @pointer = ptr
47
+ end
48
+ obj
49
+ end
50
+ end
51
+
52
+ class Keymap
53
+ def state_new
54
+ ptr = XkbSupport::F.xkb_state_new @pointer
55
+ ptr.free = XkbSupport::F[:xkb_state_unref]
56
+ obj = State.new
57
+ obj.instance_eval do
58
+ @state = self
59
+ @pointer = ptr
60
+ end
61
+ obj
62
+ end
63
+ end
64
+
65
+ class State
66
+ def key_get_one_sym(scancode)
67
+ XkbSupport::F.xkb_state_key_get_one_sym(@pointer, scancode)
68
+ end
69
+
70
+ def key_get_utf8(scancode, buffer = nil)
71
+ unless buffer
72
+ len = XkbSupport::F.xkb_state_key_get_utf8(@pointer, scancode, nil, 0)
73
+ buffer = "\0" * (len + 1)
74
+ end
75
+ len = XkbSupport::F.xkb_state_key_get_utf8(@pointer, scancode,
76
+ buffer, buffer.bytesize)
77
+ return len, buffer
78
+ end
79
+
80
+ def update_mask(depressed_mods, latched_mods, locked_mods,
81
+ depressed_layout, latched_layout, locked_layout)
82
+ XkbSupport::F.xkb_state_update_mask(@pointer,
83
+ depressed_mods, latched_mods, locked_mods,
84
+ depressed_layout, latched_layout, locked_layout)
85
+ end
86
+ end
87
+ end
88
+ end
data/lib/wayland.rb ADDED
@@ -0,0 +1,26 @@
1
+ require 'wayland/protocol'
2
+ require 'wayland/wlobject'
3
+ require 'wayland/util'
4
+
5
+ module Wayland
6
+ def self.require_wayland_core(yaml)
7
+ Protocol.load_yaml yaml
8
+ require "wayland/wl/display"
9
+ require "wayland/wl/registry"
10
+ end
11
+
12
+ def self.require_xdg_shell(yaml)
13
+ Protocol.load_yaml yaml
14
+ require 'wayland/xdg/wm_base'
15
+ end
16
+
17
+ dir = File.join(File.dirname(__FILE__), "wayland")
18
+ core_yaml =
19
+ const_defined?(:CORE_YAML) ?
20
+ CORE_YAML : File.join(dir, "wayland.yaml")
21
+ xdg_shell_yaml =
22
+ const_defined?(:XDG_BASE_YAML) ?
23
+ XDG_BASE_YAML : File.join(dir, "xdg-shell.yaml")
24
+ require_wayland_core core_yaml
25
+ require_xdg_shell xdg_shell_yaml
26
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rwayland
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - nmbits
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 2025-08-12 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: Ruby bindings for Wayland protocol.
13
+ email:
14
+ - nmbits@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - LICENSE
20
+ - README.md
21
+ - bin/scanner.rb
22
+ - example/01_wayland-book.rb
23
+ - example/02_window.rb
24
+ - example/rwaylandtk.rb
25
+ - example/rwaylandtk/custom_wl_interface.rb
26
+ - example/rwaylandtk/toplevel_window.rb
27
+ - lib/wayland.rb
28
+ - lib/wayland/cairo_support.rb
29
+ - lib/wayland/code_generator.rb
30
+ - lib/wayland/code_template.erb
31
+ - lib/wayland/dispatcher.rb
32
+ - lib/wayland/free_list.rb
33
+ - lib/wayland/message_buffer.rb
34
+ - lib/wayland/object_manager.rb
35
+ - lib/wayland/protocol.rb
36
+ - lib/wayland/scanner.rb
37
+ - lib/wayland/shared_memory.rb
38
+ - lib/wayland/util.rb
39
+ - lib/wayland/wayland.yaml
40
+ - lib/wayland/wl/display.rb
41
+ - lib/wayland/wl/registry.rb
42
+ - lib/wayland/wlobject.rb
43
+ - lib/wayland/xdg-shell.yaml
44
+ - lib/wayland/xdg/wm_base.rb
45
+ - lib/wayland/xkb_support.rb
46
+ homepage: https://github.com/nmbits/rwayland
47
+ licenses:
48
+ - MIT
49
+ metadata: {}
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '3.3'
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubygems_version: 3.6.3
65
+ specification_version: 4
66
+ summary: Ruby bindings for Wayland protocol.
67
+ test_files: []