class Xtst::RecordExtension

Defined in:

xtst/record-extension.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new #

Connects to the display and raises if Record Extension Library was not found on the system.


[View source]

Instance Method Detail

def close : Int32 #

[View source]
def create_context(range : LibXtst::RecordRange, *, flags = 0, client_spec = LibXtst::RecordClientSpec::AllClients) #

Returns a new context. A range can be created with #create_range.

Example usage:

range = record.create_range
range.device_events.first = X11::KeyPress
range.device_events.last = X11::ButtonRelease
context = record.create_context(record_range)

[View source]
def create_range #

Create a mutable range for usage in #create_context.


[View source]
def ctrl_display : X11::Display #

The underlying Display object. Docs recommend using two separate connections for control and data.


[View source]
def data_display : X11::Display #

The underlying Display object. Docs recommend using two separate connections for control and data.


[View source]
def enable_context_async(context : LibXtst::RecordContext, &callback : LibXtst::RecordInterceptData -> ) #

Start listening for the events configured in context.range. This method does not block. The block does not get run on its own, you need to additionally repeatedly call #process_replies. For the structure of record_data.data, please refer to xEvent (NOT XEvent) at _xEvent in Xproto.h. There are no docs available for this, only other reference implementations.

Example usage:

record.enable_context_async(context) do |record_data|
  next if record_data.category != Xtst::LibXtst::RecordInterceptDataCategory::FromServer.value
  xevent = record_data.data
  repeat = xevent[2] == 1
  next if repeat
  type = xevent[0]
  keycode = xevent[1]
  state = xevent[28]
  pp! type, keycode, state
end
fd = IO::FileDescriptor.new record.data_display.connection_number
loop do
  dpy_fd.wait_readable
  record.process_replies
end

[View source]
def finalize #

[View source]
def process_replies #

[View source]