Class: Windows::Engines::XWindow

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/windows/engines/xwindow.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command, options = {}, engine = nil) ⇒ XWindow

Returns a new instance of XWindow.



15
16
17
18
# File 'lib/windows/engines/xwindow.rb', line 15

def initialize(command, options = {}, engine = nil)
  @engine  = engine || WMCtrl.new
  @command = command
end

Instance Attribute Details

#commandObject

Returns the value of attribute command.



13
14
15
# File 'lib/windows/engines/xwindow.rb', line 13

def command
  @command
end

#created_atObject (readonly)

Returns the value of attribute created_at.



12
13
14
# File 'lib/windows/engines/xwindow.rb', line 12

def created_at
  @created_at
end

#engineObject (readonly)

Returns the value of attribute engine.



12
13
14
# File 'lib/windows/engines/xwindow.rb', line 12

def engine
  @engine
end

#idObject (readonly)

Returns the value of attribute id.



12
13
14
# File 'lib/windows/engines/xwindow.rb', line 12

def id
  @id
end

Instance Method Details

#action(*args) ⇒ Object



64
65
66
67
68
# File 'lib/windows/engines/xwindow.rb', line 64

def action(*args)
  create
  engine.action(id, *args)
  self
end

#closeObject



26
27
28
29
30
# File 'lib/windows/engines/xwindow.rb', line 26

def close
  action(:close)
  @id = false
  @created_at = false
end

#createObject



40
41
42
43
44
45
46
47
48
49
# File 'lib/windows/engines/xwindow.rb', line 40

def create
  return false if created_at

  window = engine.find_window(command)
  window ||= engine.spawn_window(command)

  @id         = window.id
  @created_at = Time.now
  self
end

#focusObject



32
33
34
# File 'lib/windows/engines/xwindow.rb', line 32

def focus
  action(:activate)
end

#maximizeObject



70
71
72
# File 'lib/windows/engines/xwindow.rb', line 70

def maximize
  action(:change_state, "add", "maximized_vert", "maximized_horz")
end

#move(*args) ⇒ Object



20
21
22
23
24
# File 'lib/windows/engines/xwindow.rb', line 20

def move(*args)
  args = convert_units(args)
  undock
  action(:move_resize, 0, *args)
end

#not_on_topObject



60
61
62
# File 'lib/windows/engines/xwindow.rb', line 60

def not_on_top
  action(:change_state, "remove", "above")
end

#on_topObject



56
57
58
# File 'lib/windows/engines/xwindow.rb', line 56

def on_top
  action(:change_state, "add", "above")
end

#undockObject



36
37
38
# File 'lib/windows/engines/xwindow.rb', line 36

def undock
  action(:change_state, "remove", "maximized_vert", "maximized_horz")
end

#windowObject



51
52
53
54
# File 'lib/windows/engines/xwindow.rb', line 51

def window
  create
  engine.find_window(id)
end