Class: Wmctile::WindowTiler
Instance Method Summary collapse
-
#initialize(settings, memory, wm = nil) ⇒ WindowTiler
constructor
init ##########################.
- #memory ⇒ Object
- #resize(where = 'left', portion = 0.01) ⇒ Object
- #resize_snap(where = 'left', portion = 0.01) ⇒ Object
-
#snap(where = 'left', window_str = nil, portion = 0.5) ⇒ Object
actual snapping methods #######.
-
#wm ⇒ Object
object getter methods #########.
Methods inherited from Class
Constructor Details
#initialize(settings, memory, wm = nil) ⇒ WindowTiler
init ##########################
5 6 7 8 9 |
# File 'lib/wmctile/window_tiler.rb', line 5 def initialize settings, memory, wm = nil @settings = settings @memory = memory @wm = wm end |
Instance Method Details
#memory ⇒ Object
16 17 18 |
# File 'lib/wmctile/window_tiler.rb', line 16 def memory @memory || @memory = Wmctile::Memory.new end |
#resize(where = 'left', portion = 0.01) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/wmctile/window_tiler.rb', line 34 def resize where = 'left', portion = 0.01 portion = portion.to_f # what are we moving? the last one used from these: methods = ['snap'] freshest_meth = nil freshest_time = 0 methods.each do |meth| time = self.memory.get self.wm.workspace, meth, 'time' if time > freshest_time freshest_time = time freshest_meth = meth end end # ok, got it, it's freshest_meth self.send "resize_#{ freshest_meth }", where, portion end |
#resize_snap(where = 'left', portion = 0.01) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 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 |
# File 'lib/wmctile/window_tiler.rb', line 50 def resize_snap where = 'left', portion = 0.01 portion = portion.to_f info = self.memory.get self.wm.workspace, 'snap' if info.nil? return nil end negative = case info['where'] when 'left' if where == 'left' true elsif where == 'right' false else nil end when 'right' if where == 'left' false elsif where == 'right' true else nil end when 'top' if where == 'bottom' false elsif where == 'top' true else nil end when 'bottom' if where == 'top' false elsif where == 'bottom' true else nil end end unless negative.nil? portion = -portion if negative self.snap info['where'], info['window_id'], info['portion']+portion end end |
#snap(where = 'left', window_str = nil, portion = 0.5) ⇒ Object
actual snapping methods #######
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/wmctile/window_tiler.rb', line 22 def snap where = 'left', window_str = nil, portion = 0.5 window = self.wm.get_window window_str if window how_to_move = self.wm.calculate_snap where, portion.to_f if how_to_move window.move how_to_move self.memory.set self.wm.workspace, 'snap', { 'where' => where, 'portion' => portion, 'window_id' => window.id } end end end |
#wm ⇒ Object
object getter methods #########
13 14 15 |
# File 'lib/wmctile/window_tiler.rb', line 13 def wm @wm || @wm = Wmctile::WindowManager.new(@settings) end |