Class: XlibObj::Extension::XRR::Event

Inherits:
Object
  • Object
show all
Defined in:
lib/extension/xrr/event.rb

Constant Summary collapse

MASKS =
{
  screen_change_notify:     Xlib::RRScreenChangeNotifyMask,
  crtc_change_notify:       Xlib::RRCrtcChangeNotifyMask,
  output_change_notify:     Xlib::RROutputChangeNotifyMask,
  output_property_notify:   Xlib::RROutputPropertyNotifyMask,
  provider_change_notify:   Xlib::RRProviderChangeNotifyMask,
  provider_property_notify: Xlib::RRProviderPropertyNotifyMask,
  resource_change_notify:   Xlib::RRResourceChangeNotifyMask
}
TYPES =
{
  screen_change_notify: Xlib::RRScreenChangeNotify,
  notify:               Xlib::RRNotify
}
SUBTYPES =
{
  crtc_change_notify:       Xlib::RRNotify_CrtcChange,
  output_change_notify:     Xlib::RRNotify_OutputChange,
  output_property_notify:   Xlib::RRNotify_OutputProperty,
  provider_change_notify:   Xlib::RRNotify_ProviderChange,
  provider_property_notify: Xlib::RRNotify_ProviderProperty,
  resource_change_notify:   Xlib::RRNotify_ResourceChange
}
TYPE_TO_STRUCT =
{
  Xlib::RRScreenChangeNotify => Xlib::XRRScreenChangeNotifyEvent,
  Xlib::RRNotify             => Xlib::XRRNotifyEvent
}
SUBTYPE_TO_STRUCT =
{
  Xlib::RRNotify_CrtcChange       => Xlib::XRRCrtcChangeNotifyEvent,
  Xlib::RRNotify_OutputChange     => Xlib::XRROutputChangeNotifyEvent,
  Xlib::RRNotify_OutputProperty   => Xlib::XRROutputPropertyNotifyEvent,
  Xlib::RRNotify_ProviderChange   => Xlib::XRRProviderChangeNotifyEvent,
  Xlib::RRNotify_ProviderProperty => Xlib::XRRProviderPropertyNotifyEvent,
  Xlib::RRNotify_ResourceChange   => Xlib::XRRResourceChangeNotifyEvent
}

Instance Method Summary collapse

Constructor Details

#initialize(extension, event) ⇒ Event



12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/extension/xrr/event.rb', line 12

def initialize(extension, event)
  @extension = extension
  @xrr_type = event[:type] - extension.first_event

  type_struct = TYPE_TO_STRUCT[@xrr_type].new(event.pointer)

  @struct = if type_struct.members.include?(:subtype)
    SUBTYPE_TO_STRUCT[type_struct[:subtype]].new(event.pointer)
  else
    type_struct
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name) ⇒ Object



33
34
35
# File 'lib/extension/xrr/event.rb', line 33

def method_missing(name)
  @struct.members.include?(name) ? @struct[name] : nil
end

Instance Method Details

#handleObject



25
26
27
# File 'lib/extension/xrr/event.rb', line 25

def handle
  Window.new(@extension.display, window).handle(self)
end

#nameObject



29
30
31
# File 'lib/extension/xrr/event.rb', line 29

def name
  @name ||= subtype ? SUBTYPES.key(subtype) : TYPES.key(@xrr_type)
end