Class: XAutoBrowse::Window

Inherits:
XTabbedWindow
  • Object
show all
Defined in:
lib/xautobrowse.rb

Instance Method Summary collapse

Constructor Details

#initialize(browser = nil, new_win: true, scan_tabs: false, debug: false) ⇒ Window

Returns a new instance of Window.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/xautobrowse.rb', line 65

def initialize(browser=nil, new_win: true, scan_tabs: false, debug: false)

  @wm, @debug = WMCtrl.display, debug

  if browser then

    if new_win then

      puts 'ready to spawn' if @debug
      spawn(browser.to_s);
      sleep 3

      #jr2022-06-09 puts 'waiting for window: ' + browser.to_s.inspect if @debug
      #jr2022-06-09 id = XDo::XWindow.wait_for_window(browser.to_s)

      #jr2022-06-09 xwin = XDo::XWindow.new(id)
      #jr2022-06-09 title = xwin.title
      #jr2022-06-09 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

Instance Method Details

#activateObject



105
106
107
# File 'lib/xautobrowse.rb', line 105

def activate()
  @wm.action_window(@id, :activate)
end

#height=(val) ⇒ Object



109
110
111
112
# File 'lib/xautobrowse.rb', line 109

def height=(val)
  @height = val
  @wm.action_window(@id, :move_resize, 0, @x, @y, @width, @height)
end

#move(x, y) ⇒ Object



114
115
116
117
# File 'lib/xautobrowse.rb', line 114

def move(x,y)
  @x, @y = x, y
  @wm.action_window(@id, :move_resize, 0, @x, @y, @width, @height)
end

#resize_to(width, height) ⇒ Object Also known as: resize



119
120
121
122
# File 'lib/xautobrowse.rb', line 119

def resize_to(width, height)
  @width, @height = width, height
  @wm.action_window(@id, :move_resize, 0, @x, @y, @width, @height)
end

#width=(val) ⇒ Object



126
127
128
129
# File 'lib/xautobrowse.rb', line 126

def width=(val)
  @width = val
  @wm.action_window(@id, :move_resize, 0, @x, @y, @width, @height)
end