commit 02c9c790a5db40d0afae658a82fa6953e5010ab6
parent cdaf073608aac3edeb2823b13c43478db9ab6fd7
Author: Suraj N. Kurapati <sunaku@gmail.com>
Date: Wed, 13 Sep 2006 06:36:47 -0700
[project @ 75f77d3da8402e3ebf7b1fcd689b9382734c6dbe]
[project @ 84]
add Area#length & #length
Diffstat:
3 files changed, 27 insertions(+), 24 deletions(-)
diff --git a/HISTORY b/HISTORY
@@ -1,10 +1,9 @@
-= History
-
This is a history of major changes to {my wmii configuration}[http://people.ucsc.edu/~skurapat/wmii.html].
= 2006-09-12
* Event loop now uses Ixp#read instead of wmiir.
+ * Already running configurations now correctly exit when another instance starts up.
= 2006-09-11
@@ -12,7 +11,7 @@ This is a history of major changes to {my wmii configuration}[http://people.ucsc
* Added exception logging and recovery mechanism.
* wmiirc is now split into a loader file (wmiirc) and a configuration file (wmiirc-config.rb), just like in the ruby-wmii project.
-* +IXPException+s are no longer hidden away inside Ixp.
+* IXPException' are no longer hidden away inside Ixp.
* Moved support for destructive area-operations from Wmii#with_selection into Array#each so that it is generally available.
diff --git a/wm.rb b/wm.rb
@@ -328,6 +328,28 @@ module Wmii
push! aArea.clients
end
+ # Returns the number of clients in this area.
+ def length
+ self.indices.length
+ end
+
+ # Tries to have at most the given number of clients in this area. Areas to the right of this one serve as a buffer into which excess clients are evicted and from which deficit clients are imported.
+ def length= aMaxClients
+ return if aMaxClients < 0
+
+ if length > aMaxClients
+ self.next.unshift! clients[aMaxClients..-1]
+
+ elsif length < aMaxClients
+ until (diff = aMaxClients - length) == 0
+ immigrants = self.next.clients[0...diff]
+ break if immigrants.empty?
+
+ push! immigrants
+ end
+ end
+ end
+
private
# Updates the path of this area for proper insertion and inserts the given client.
def setup_for_insertion! aFirstClient
@@ -422,26 +444,8 @@ module Wmii
until i >= (areaList = self.areas).length
a = areaList[i]
-
-
- a.mode = 'default'
- clientList = a.clients
-
- if clientList.length > aMaxClientsPerColumn
- # evict excess clients to next column
- emigrants = clientList[aMaxClientsPerColumn..-1]
- a.next.unshift! emigrants
-
- elsif clientList.length < aMaxClientsPerColumn
- # import clients from next column
- until (diff = aMaxClientsPerColumn - a.clients.length) == 0
- immigrants = a.next.clients[0...diff]
- break if immigrants.empty?
-
- a.push! immigrants
- end
- end
-
+ a.mode = :default
+ a.length = aMaxClientsPerColumn
i += 1
end
diff --git a/wmiirc-config.rb b/wmiirc-config.rb
@@ -389,7 +389,7 @@ begin
case type
when 'Start'
if arg == __FILE__
- LOG.info($$) {"exiting because another is starting"}
+ LOG.info($$) {"another config is starting"}
exit
end