Class: KDE::Window

Inherits:
Object
  • Object
show all
Defined in:
lib/scite/window.rb

Overview

Basic operations over windows in KDE.

Direct Known Subclasses

SciTE::Window

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title: nil, pid: nil, wid: nil) ⇒ Window

Returns a new instance of Window.



20
21
22
23
# File 'lib/scite/window.rb', line 20

def initialize(title: nil, pid: nil, wid: nil)
  @title, @pid, @wid = title, pid, wid
  @threads = []
end

Instance Attribute Details

#pidObject (readonly)

Returns the value of attribute pid.



9
10
11
# File 'lib/scite/window.rb', line 9

def pid
  @pid
end

#positionObject

Returns the value of attribute position.



9
10
11
# File 'lib/scite/window.rb', line 9

def position
  @position
end

#titleObject

Returns the value of attribute title.



9
10
11
# File 'lib/scite/window.rb', line 9

def title
  @title
end

Class Method Details

.find(title: nil) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/scite/window.rb', line 12

def self.find(title: nil)
  if title
    if info = `wmctrl -l -p`[/^(0x\w+) +-?\d+ (\d+) .+ #{title}$/]
      new title: title, pid: $2.to_i, wid: $1
    end
  end
end

Instance Method Details

#move(frames: 20, duration: 400.0, **coords) ⇒ Object



53
54
55
56
57
58
59
# File 'lib/scite/window.rb', line 53

def move(frames: 20, duration: 400.0, **coords)
  coords.reverse_merge! position
  #$log << [position, coords, {frames: frames, duration: duration}]
  Animation.perform(position, coords, frames: frames, duration: duration) {|coords|
    self.position = coords
  }
end

#waitObject



25
26
27
28
29
# File 'lib/scite/window.rb', line 25

def wait
  @threads.joins
  @threads = []
  self
end

#widObject



31
32
33
# File 'lib/scite/window.rb', line 31

def wid
  @wid ||= `wmctrl -l -p | grep " #@pid "`[/0x\w+/]
end