class X11::Window

An X11 Window (toplevel window, widget, applet, etc.) Represented by its XID, an unsigned long.

Attributes

class[R]
hint[R]
name[R]
parent[R]
xid[R]

Public Class Methods

new(xid,screen_num,xdisplay,parent=nil) click to toggle source
# 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

Public Instance Methods

children() click to toggle source

Child windows

# File lib/firewatir/x11.rb, line 115
def children
        tree[:children].collect{|c| Window.new(c,@screen_num,@xdisplay,self)}
end
parent_xid() click to toggle source

XID of parent window

# File lib/firewatir/x11.rb, line 120
def parent_xid
        parent ? parent.xid : nil
end
send_key(key=:enter,sleep=nil) click to toggle source

Send a key press to this window

# 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