Class: X11::Window
- Inherits:
-
Object
- Object
- X11::Window
- Defined in:
- lib/firewatir/x11.rb
Overview
An X11 Window (toplevel window, widget, applet, etc.) Represented by its XID, an unsigned long.
Instance Attribute Summary collapse
-
#class ⇒ Object
readonly
Returns the value of attribute class.
-
#hint ⇒ Object
readonly
Returns the value of attribute hint.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
-
#xid ⇒ Object
readonly
Returns the value of attribute xid.
Instance Method Summary collapse
-
#children ⇒ Object
Child windows.
-
#initialize(xid, screen_num, xdisplay, parent = nil) ⇒ Window
constructor
A new instance of Window.
-
#parent_xid ⇒ Object
XID of parent window.
-
#send_key(key = :enter, sleep = nil) ⇒ Object
Send a key press to this window.
Constructor Details
#initialize(xid, screen_num, xdisplay, parent = nil) ⇒ Window
Returns a new instance of Window.
106 107 108 109 110 111 112 |
# File 'lib/firewatir/x11.rb', line 106 def initialize(xid,screen_num,xdisplay,parent=nil) @xid = xid @screen_num = screen_num @xdisplay = xdisplay @parent = parent load_standard end |
Instance Attribute Details
#class ⇒ Object (readonly)
Returns the value of attribute class.
104 105 106 |
# File 'lib/firewatir/x11.rb', line 104 def class @class end |
#hint ⇒ Object (readonly)
Returns the value of attribute hint.
104 105 106 |
# File 'lib/firewatir/x11.rb', line 104 def hint @hint end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
104 105 106 |
# File 'lib/firewatir/x11.rb', line 104 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
104 105 106 |
# File 'lib/firewatir/x11.rb', line 104 def parent @parent end |
#xid ⇒ Object (readonly)
Returns the value of attribute xid.
104 105 106 |
# File 'lib/firewatir/x11.rb', line 104 def xid @xid end |
Instance Method Details
#children ⇒ Object
Child windows
115 116 117 |
# File 'lib/firewatir/x11.rb', line 115 def children tree[:children].collect{|c| Window.new(c,@screen_num,@xdisplay,self)} end |
#parent_xid ⇒ Object
XID of parent window
120 121 122 |
# File 'lib/firewatir/x11.rb', line 120 def parent_xid parent ? parent.xid : nil end |
#send_key(key = :enter, sleep = nil) ⇒ Object
Send a key press to this window
125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/firewatir/x11.rb', line 125 def send_key(key=:enter,sleep=nil) # TODO expand this list out, add support for shift, etc. @@keys = {:enter => 36, :tab => 23} unless defined?@@keys keycode = @@keys[key] X11.xSetInputFocus(@xdisplay, @xid, 1, 0) sleep(sleep) if sleep e = create_key_event e.keycode = keycode e.type = 2 # press X11.xSendEvent(@xdisplay,@xid,1,1,e) e.type = 3 # release X11.xSendEvent(@xdisplay,@xid,1,2,e) X11.xFlush(@xdisplay) end |