Class: X11::Window

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#classObject (readonly)

Returns the value of attribute class.



104
105
106
# File 'lib/firewatir/x11.rb', line 104

def class
  @class
end

#hintObject (readonly)

Returns the value of attribute hint.



104
105
106
# File 'lib/firewatir/x11.rb', line 104

def hint
  @hint
end

#nameObject (readonly)

Returns the value of attribute name.



104
105
106
# File 'lib/firewatir/x11.rb', line 104

def name
  @name
end

#parentObject (readonly)

Returns the value of attribute parent.



104
105
106
# File 'lib/firewatir/x11.rb', line 104

def parent
  @parent
end

#xidObject (readonly)

Returns the value of attribute xid.



104
105
106
# File 'lib/firewatir/x11.rb', line 104

def xid
  @xid
end

Instance Method Details

#childrenObject

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_xidObject

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