class Vigilem::X11::EventQueue
Attributes
Public Class Methods
finds an existing EventQueue
with the given display or returns a new one based on the items passed in @param [Display || FFI::Pointer || String]
display_obj_pointer_or_name
@return [EventQueue]
# File lib/vigilem/x11/event_queue.rb, line 39 def acquire(display_obj_pointer_or_name) dip = Display.wrap(display_obj_pointer_or_name) eventq = all.find {|evq| evq.fileno == dip.fileno } eventq || new(dip) end
@param [String || Display
|| ::FFI::Pointer]
display_pointer_or_name
# File lib/vigilem/x11/event_queue.rb, line 27 def new(display_obj_pointer_or_name) ret = obj_register(super(display_obj_pointer_or_name)) same_display_check! ret end
@param [String || Display
|| ::FFI::Pointer]
display_pointer_or_name
# File lib/vigilem/x11/event_queue.rb, line 67 def initialize(display_obj_pointer_or_name) @display = Display.wrap(display_obj_pointer_or_name) end
@return [Array]
# File lib/vigilem/x11/event_queue.rb, line 48 def same_display_check all.group_by {|ev| ev.display.fileno }.select {|k, v| v.size > 1 } end
@param [StandardError] err_type, defaults to ArgumentError @raise “EventQueues should not have the same display `#{array of event queues with same display}'” @return [NilClass]
# File lib/vigilem/x11/event_queue.rb, line 56 def same_display_check!(err_type=ArgumentError) unless (dups = same_display_check).empty? raise err_type, "EventQueues should not have the same display `#{dups}'" end end
Public Instance Methods
@raise [NotImplemented]
# File lib/vigilem/x11/event_queue.rb, line 125 def concat(*args) raise NotImplementedError end
@raise [ArgumentError] @return
# File lib/vigilem/x11/event_queue.rb, line 101 def display! # a way to validate the pointer to prevent segfault? if display.is_a?(::FFI::Pointer) or display.respond_to?(:to_ptr) display else raise ArgumentError, "Display is a `#{display.inspect}'" + "and doesn't respond to :to_ptr" end end
@return [Fixnum]
# File lib/vigilem/x11/event_queue.rb, line 94 def fileno @fileno ||= display.fileno end
@return [Xlib::XEvent]
# File lib/vigilem/x11/event_queue.rb, line 86 def next_event x_event = Xlib::XEvent.new Xlib.XNextEvent(display!, x_event) x_event end
@raise [NotImplemented]
# File lib/vigilem/x11/event_queue.rb, line 131 def peek raise NotImplementedError # @todo #if _internal_buffer.size > 0 # _internal_buffer[0] #else # if pending! > 0 # next_event # end #end end
the XPending and items pulled from the queue that haven't propagated @return [Fixnum]
# File lib/vigilem/x11/event_queue.rb, line 74 def pending pending! + _internal_buffer.size end
only the number of events returned by XPending @return [Fixnum]
# File lib/vigilem/x11/event_queue.rb, line 80 def pending! Xlib.XPending(display!) end
@param [Integer || Range] start_idx_range @param [Integer] len @return [Array]
# File lib/vigilem/x11/event_queue.rb, line 115 def slice!(start_idx_range, len=nil) # this isn;t the most efficient way, but is the # most straight forward pending!.times.map do next_event end.compact.slice!(start_idx_range, *len) end
Private Instance Methods
@return [Array]
# File lib/vigilem/x11/event_queue.rb, line 146 def _internal_buffer @internal_buffer ||= [] end