Class: ActiveWindowX::Display
- Inherits:
-
Object
- Object
- ActiveWindowX::Display
- Defined in:
- lib/active_window_x/display.rb,
lib/active_window_x.rb
Overview
binding for Display on X11
Instance Attribute Summary collapse
-
#closed ⇒ Object
(also: #closed?)
readonly
a boolean which be true if this display was closed.
-
#raw ⇒ Object
readonly
raw class of Display.
Instance Method Summary collapse
- #active_window ⇒ Object
- #atom_name(id) ⇒ Object
- #close ⇒ Object
-
#connection ⇒ Object
return IO to select and poll a XEvent with timeout.
-
#initialize(arg = nil) ⇒ Display
constructor
A new instance of Display.
- #intern_atom(name) ⇒ Object
- #next_event ⇒ Object
-
#pending ⇒ Object
return the number of events that have been received from the X server.
- #root_window ⇒ Object
Constructor Details
#initialize(arg = nil) ⇒ Display
Returns a new instance of Display.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/active_window_x/display.rb', line 15 def initialize arg=nil @raw = if arg.nil? or arg.kind_of? String Xlib::x_open_display arg elsif arg.kind_of? Xlib::Display arg else raise ArgumentError, 'expect nil, String or Xlib::Display' end @closed = false @root_window = nil @cache = {} end |
Instance Attribute Details
#closed ⇒ Object (readonly) Also known as: closed?
a boolean which be true if this display was closed
12 13 14 |
# File 'lib/active_window_x/display.rb', line 12 def closed @closed end |
#raw ⇒ Object (readonly)
raw class of Display
9 10 11 |
# File 'lib/active_window_x/display.rb', line 9 def raw @raw end |
Instance Method Details
#active_window ⇒ Object
48 49 50 |
# File 'lib/active_window_x/display.rb', line 48 def active_window root_window.active_window end |
#atom_name(id) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/active_window_x/display.rb', line 60 def atom_name id if @cache.has_key? id @cache[id] else @cache[id] = Xlib::x_get_atom_name @raw, id end end |
#close ⇒ Object
29 30 31 32 |
# File 'lib/active_window_x/display.rb', line 29 def close Xlib::x_close_display @raw @closed = true end |
#connection ⇒ Object
return IO to select and poll a XEvent with timeout
39 40 41 |
# File 'lib/active_window_x/display.rb', line 39 def connection @conn ||= IO.new(Xlib::connection_number @raw) end |
#intern_atom(name) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/active_window_x/display.rb', line 52 def intern_atom name if @cache.has_key? name @cache[name] else @cache[name] = Xlib::x_intern_atom @raw, name, false end end |
#next_event ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/active_window_x/display.rb', line 68 def next_event xevent = Xlib::x_next_event @raw case xevent.type when Xlib::PropertyNotify; PropertyEvent.new self, xevent when Xlib::ClientMessage; ClientMessageEvent.new self, xevent else Event.new self, xevent end end |
#pending ⇒ Object
return the number of events that have been received from the X server
44 45 46 |
# File 'lib/active_window_x/display.rb', line 44 def pending Xlib::x_pending @raw end |
#root_window ⇒ Object
34 35 36 |
# File 'lib/active_window_x/display.rb', line 34 def root_window @root_window ||= RootWindow.new(self, Xlib::default_root_window(@raw)) end |