Class: RBGL::GUI::Wayland::GlobalBinder

Inherits:
Object
  • Object
show all
Defined in:
lib/rbgl/gui/wayland/global_binder.rb

Constant Summary collapse

BINDINGS =
{
  "wl_compositor" => [:compositor, Compositor, 4],
  "wl_shm" => [:shm, Shm, 1],
  "xdg_wm_base" => [:xdg_wm_base, XdgWmBase, 2]
}.freeze
REQUIRED_INTERFACES =
BINDINGS.keys.freeze

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ GlobalBinder

Returns a new instance of GlobalBinder.



16
17
18
# File 'lib/rbgl/gui/wayland/global_binder.rb', line 16

def initialize(connection)
  @connection = connection
end

Instance Method Details

#bind!(registry, globals) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rbgl/gui/wayland/global_binder.rb', line 20

def bind!(registry, globals)
  validate_required_globals!(globals)

  BINDINGS.each_with_object({}) do |(interface, binding), bound|
    slot, klass, max_version = binding
    global = globals[interface]
    next unless global

    object_id = registry.bind(global[:name], interface, [global[:version], max_version].min)
    bound[slot] = @connection.register_object(klass.new(@connection, object_id))
  end
end