commit e7333bb18a2d3996e7092783a87d1eb3499633cd
parent 13c31a5482567ae871bde642c75bdd47e7c2432d
Author: Suraj N. Kurapati <sunaku@gmail.com>
Date: Mon, 11 Sep 2006 10:53:22 -0700
[project @ df0b37c6aceb708c9d04523bc0d8f82a8b16e471]
[project @ 69]
mv some methods from Wmii::State into Wmii
Diffstat:
rc.rb | | | 10 | +++++----- |
wm.rb | | | 49 | ++++++++++++++++++++++--------------------------- |
2 files changed, 27 insertions(+), 32 deletions(-)
diff --git a/rc.rb b/rc.rb
@@ -91,7 +91,7 @@ end
# Send selected clients to temporary view or switch back again.
def toggle_temporary_view
- curView = focused_view.name
+ curView = current_view.name
if curView =~ /~\d+$/
with_selection do |c|
@@ -113,14 +113,14 @@ def toggle_temporary_view
end
focus_view tmpView
- focused_view.grid!
+ current_view.grid!
end
end
-# Changes the currently focused view to an adjacent one (:left or :right).
+# Puts focus on an adjacent view (:left or :right).
def cycle_view aTarget
tags = self.tags
- curTag = focused_view.name
+ curTag = current_view.name
curIndex = tags.index(curTag)
newIndex =
@@ -155,7 +155,7 @@ end
def attach_last_client
if a = View.new("/#{DETACHED_TAG}").areas.last
if c = a.clients.last
- c.tags = focused_view.name
+ c.tags = current_view.name
end
end
end
diff --git a/wm.rb b/wm.rb
@@ -50,22 +50,36 @@ module Wmii
nil
end
+ # Focuses the view with the given name.
+ def focus_view aName
+ View.new("/#{aName}").focus!
+ end
+
+ # Focuses the client which has the given ID.
+ def focus_client aClientId
+ if c = find_client(aClientId)
+ v = (a = c.parent).parent
+
+ v.focus!
+ a.focus!
+ c.focus!
+ end
+ end
+
# Encapsulates the window manager's state.
module State
- ## state access
-
# Returns the currently focused client.
- def focused_client
+ def current_client
Client.new("/view/sel/sel")
end
# Returns the currently focused area.
- def focused_area
+ def current_area
Area.new("/view/sel")
end
# Returns the currently focused view.
- def focused_view
+ def current_view
View.new("/view")
end
@@ -85,36 +99,17 @@ module Wmii
end
- ## state manipulation
-
- # Focuses the view with the given name.
- def focus_view aName
- View.new("/#{aName}").focus!
- end
-
- # Focuses the client which has the given ID.
- def focus_client aClientId
- if c = find_client(aClientId)
- v = (a = c.parent).parent
-
- v.focus!
- a.focus!
- c.focus!
- end
- end
-
-
## Multiple client selection
# Returns a list of all selected clients in the currently focused view. If there are no selected clients, then the currently focused client is returned in the list.
def selected_clients
- list = focused_view.areas.map do |a|
+ list = current_view.areas.map do |a|
a.clients.select {|c| c.selected?}
end
list.flatten!
if list.empty?
- list << focused_client
+ list << current_client
end
list
@@ -129,7 +124,7 @@ module Wmii
def with_selection # :yields: client
return unless block_given?
- curView = focused_view
+ curView = current_view
selected_clients.each do |c|
# resolve stale paths caused by destructive operations