Class: WMCtrl::Window

Inherits:
DataHash show all
Defined in:
lib/wmctrl/wmctrl.rb

Instance Method Summary collapse

Methods inherited from DataHash

#initialize, #method_missing

Constructor Details

This class inherits a constructor from WMCtrl::DataHash

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class WMCtrl::DataHash

Instance Method Details

#[](key) ⇒ Object

Parameters:

  • key (Symbol)

    Valid keys are :class, :id, :title, :active, :desktop, :client_machine, :pid, :geometry, :state, :exterior_frame, :frame_extents, and :strut. :wm_class is an alias of :class.



97
98
99
100
101
102
103
# File 'lib/wmctrl/wmctrl.rb', line 97

def [](key)
  if key == :wm_class
    self.wm_class
  else
    super(key)
  end
end

#activateObject



161
162
163
# File 'lib/wmctrl/wmctrl.rb', line 161

def activate
  action(:activate)
end

#active?Boolean

Returns:

  • (Boolean)


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

def active?
  self[:active]
end

#change_state(*args) ⇒ Object



157
158
159
# File 'lib/wmctrl/wmctrl.rb', line 157

def change_state(*args)
  action(:change_state, *args)
end

#closeObject



153
154
155
# File 'lib/wmctrl/wmctrl.rb', line 153

def close
  action(:close)
end

#fullscreen?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/wmctrl/wmctrl.rb', line 113

def fullscreen?
  self[:state].include?("_NET_WM_STATE_FULLSCREEN")
end

#hidden?Boolean

Returns:

  • (Boolean)


133
134
135
# File 'lib/wmctrl/wmctrl.rb', line 133

def hidden?
  self[:state].include?("_NET_WM_STATE_HIDDEN")
end

#maximized_horizontally?Boolean

Returns:

  • (Boolean)


125
126
127
# File 'lib/wmctrl/wmctrl.rb', line 125

def maximized_horizontally?
  self[:state].include?("_NET_WM_STATE_MAXIMIZED_HORZ")
end

#maximized_vertically?Boolean

Returns:

  • (Boolean)


121
122
123
# File 'lib/wmctrl/wmctrl.rb', line 121

def maximized_vertically?
  self[:state].include?("_NET_WM_STATE_MAXIMIZED_VERT")
end

#modal?Boolean

Returns:

  • (Boolean)


117
118
119
# File 'lib/wmctrl/wmctrl.rb', line 117

def modal?
  self[:state].include?("_NET_WM_STATE_MODAL")
end

#place(opts = {}) ⇒ Object

Parameters:

  • opts (Hash) (defaults to: {})

    Options

Options Hash (opts):

  • :x (Integer)

    X coordinate

  • :y (Integer)

    Y coordinate

  • :width (Integer)

    Width of window

  • :height (Integer)

    Height of window

  • :desktop (Integer, :current)

    Desktop number

  • :gravity (Integer)

    Number meaning gravity: NOT_USE_NET_MOVERESIZE_WINDOW, GRAVITY_DEFAULT, GRAVITY_NORTH_WEST, GRAVITY_NORTH, GRAVITY_NORTH_EAST, GRAVITY_WEST, GRAVITY_CENTER, GRAVITY_EAST, GRAVITY_SOUTH_WEST, GRAVITY_SOUTH, GRAVITY_SOUTH_EAST, GRAVITY_STATIC



174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
# File 'lib/wmctrl/wmctrl.rb', line 174

def place(opts = {})
  if opts[:desktop]
    if opts[:desktop] == :current
      action(:move_to_current)
    elsif (opts[:desktop] != self[:desktop])
      action(:move_to_desktop, opts[:desktop])
    end
  end
  gravity = opts[:gravity] || GRAVITY_DEFAULT
  x = self[:exterior_frame][0]
  y = self[:exterior_frame][1]
  width = self[:exterior_frame][2]
  height = self[:exterior_frame][3]
  extent_horizontal = self[:frame_extents][0] + self[:frame_extents][1]
  extent_vertical = self[:frame_extents][2] + self[:frame_extents][3]
  width = opts[:width] if opts[:width] && (opts[:width] != width)
  height = opts[:height] if opts[:height] && (opts[:height] != height)
  x = opts[:x] if opts[:x] && (opts[:x] != x)
  y = opts[:y] if opts[:y] && (opts[:y] != y)
  action(:move_resize, gravity, x + self[:frame_extents][0], y + self[:frame_extents][1], width - extent_horizontal, height - extent_vertical)
end

#positionObject



196
197
198
199
# File 'lib/wmctrl/wmctrl.rb', line 196

def position
  a = self[:exterior_frame]
  { :x => a[0], :y => a[1], :width => a[2], :height => a[3] }
end

#shaded?Boolean

Returns:

  • (Boolean)


129
130
131
# File 'lib/wmctrl/wmctrl.rb', line 129

def shaded?
  self[:state].include?("_NET_WM_STATE_SHADED")
end

#skipped_by_pager?Boolean

Returns:

  • (Boolean)


141
142
143
# File 'lib/wmctrl/wmctrl.rb', line 141

def skipped_by_pager?
  self[:state].include?("_NET_WM_STATE_SKIP_PAGER")
end

#skipped_by_taskbar?Boolean

Returns:

  • (Boolean)


137
138
139
# File 'lib/wmctrl/wmctrl.rb', line 137

def skipped_by_taskbar?
  self[:state].include?("_NET_WM_STATE_SKIP_TASKBAR")
end

#sticky?Boolean

Returns:

  • (Boolean)


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

def sticky?
  self[:desktop] == -1
end

#wm_classObject

Because method name "class" is a basic ruby method, we use "wm_class" to get window class.



90
91
92
# File 'lib/wmctrl/wmctrl.rb', line 90

def wm_class
  self[:class]
end