class XAutoBrowse::Window

Public Class Methods

new(browser=nil, new_win: true, scan_tabs: false) click to toggle source
Calls superclass method
# File lib/xautobrowse.rb, line 65
def initialize(browser=nil, new_win: true, scan_tabs: false)
        
  @wm = WMCtrl.instance
  
  if browser then
    
    if new_win then
      spawn(browser.to_s); sleep 3
      
      id = XDo::XWindow.wait_for_window(browser.to_s)

      xwin = XDo::XWindow.new(id)
      title = xwin.title
      puts 'title:  ' + title.inspect if @debug

      # WMCtrl is used because XDo is problematic at trying to activate a window
      
      a = @wm.list_windows true
      puts 'a: '  + a.inspect if @debug
      r = a.reverse.find {|x| x[:title] =~ /#{browser}$/i}
    else
      super(browser, scan_tabs: scan_tabs)
      r = @window
    end
  else
    a = @wm.list_windows true
    r = a.last
  end      
  
  @id = r[:id]

  @x, @y, @width, @height = *r[:geometry]      
  sleep 4 unless browser
  
end

Public Instance Methods

activate() click to toggle source
# File lib/xautobrowse.rb, line 101
def activate()
  @wm.action_window(@id, :activate)
end
height=(val) click to toggle source
# File lib/xautobrowse.rb, line 105
def height=(val)
  @height = val
  @wm.action_window(@id, :move_resize, 0, @x, @y, @width, @height)
end
move(x,y) click to toggle source
# File lib/xautobrowse.rb, line 110
def move(x,y)
  @x, @y = x, y
  @wm.action_window(@id, :move_resize, 0, @x, @y, @width, @height)
end
resize(width, height)
Alias for: resize_to
resize_to(width, height) click to toggle source
# File lib/xautobrowse.rb, line 115
def resize_to(width, height)
  @width, @height = width, height
  @wm.action_window(@id, :move_resize, 0, @x, @y, @width, @height)
end
Also aliased as: resize
width=(val) click to toggle source
# File lib/xautobrowse.rb, line 122
def width=(val)
  @width = val
  @wm.action_window(@id, :move_resize, 0, @x, @y, @width, @height)
end