Class: Xlib::XI::EventMask
- Inherits:
-
Object
- Object
- Xlib::XI::EventMask
- Defined in:
- lib/xlib/xi/event_mask.rb
Instance Attribute Summary collapse
-
#devices ⇒ Object
readonly
Returns the value of attribute devices.
-
#mask ⇒ Object
readonly
Returns the value of attribute mask.
Instance Method Summary collapse
-
#initialize(devices, mask) ⇒ EventMask
constructor
A new instance of EventMask.
- #to_native ⇒ Object
Constructor Details
#initialize(devices, mask) ⇒ EventMask
Returns a new instance of EventMask.
4 5 6 7 |
# File 'lib/xlib/xi/event_mask.rb', line 4 def initialize(devices, mask) @devices = [*devices] @mask = mask end |
Instance Attribute Details
#devices ⇒ Object (readonly)
Returns the value of attribute devices.
9 10 11 |
# File 'lib/xlib/xi/event_mask.rb', line 9 def devices @devices end |
#mask ⇒ Object (readonly)
Returns the value of attribute mask.
9 10 11 |
# File 'lib/xlib/xi/event_mask.rb', line 9 def mask @mask end |
Instance Method Details
#to_native ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/xlib/xi/event_mask.rb', line 11 def to_native @structs ||= begin masks_ptr = FFI::MemoryPointer.new(Xlib::XIEventMask.size, @devices.count) @devices.each.with_index do |device, idx| byte_length = (@mask.bit_length/8.0).ceil mask_ptr = FFI::MemoryPointer.new :int mask_ptr.write_int @mask Xlib::XIEventMask.new(masks_ptr[idx]).tap do |event_mask| event_mask[:deviceid] = device.is_a?(XlibObj::InputDevice) ? device.id : device event_mask[:mask_len] = FFI.type_size(:int) event_mask[:mask] = mask_ptr end end Xlib::XIEventMask.new(masks_ptr[0]).pointer end end |