From 6a1a24c25d09698e37cb7eb09bbbed4c8d50e735 Mon Sep 17 00:00:00 2001
From: Fabian Homborg <FHomborg@gmail.com>
Date: Fri, 9 Aug 2013 01:58:59 +0200
Subject: [PATCH] Let floating clients stay above tiled ones, by using the
 keepAbove property

This also fixes a bug with tiling because a method was missing.
---
 commentary.org                 |  3 ++-
 contents/code/tile.js          | 17 +++++++++++++----
 contents/code/tilelist.js      |  1 +
 contents/code/tilingmanager.js |  3 +--
 4 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/commentary.org b/commentary.org
index 7f110a2..376ee8f 100644
--- a/commentary.org
+++ b/commentary.org
@@ -5,8 +5,9 @@
 ** DONE Toggle floating
    Somehow client.tiling_floating stays the same across acesses
 ** DONE Floating layout/disable script
-** TODO Make floating windows be _above_ tilers
+** DONE Make floating windows be _above_ tilers
    Somehow accessing client.keepAbove doesn't work
+   Make configurable?
 * TODO EDGECASES, EDGECASES, EDGECASES!
 ** TODO Doesn't tile properly when screen disappears
 ** TODO Don't tile fullscreen windows on workspace change
diff --git a/contents/code/tile.js b/contents/code/tile.js
index 29c630c..7ebcef0 100644
--- a/contents/code/tile.js
+++ b/contents/code/tile.js
@@ -177,6 +177,15 @@ Tile.prototype._computeForcedFloating = function() {
     return forcedFloating;
 };
 
+Tile.prototype._recomputeForcedFloating = function(client) {
+	var forcedFloating = false;
+    if (client.shade || client.minimized || client.keepAbove
+        || client.fullScreen || !client.resizeable) {
+        forcedFloating = true;
+	}
+	return forcedFloating;
+}
+
 Tile.prototype._updateForcedFloating = function() {
     var forcedFloating = this._computeForcedFloating();
     if (forcedFloating == this.forcedFloating) {
@@ -187,7 +196,7 @@ Tile.prototype._updateForcedFloating = function() {
 };
 
 Tile.prototype.onClientShadeChanged = function(client) {
-    this._recomputeForcedFloating();
+    this._recomputeForcedFloating(client);
 };
 
 Tile.prototype.onClientGeometryChanged = function(client) {
@@ -208,7 +217,7 @@ Tile.prototype.onClientGeometryChanged = function(client) {
 };
 
 Tile.prototype.onClientKeepAboveChanged = function(client) {
-    this._recomputeForcedFloating();
+    this._recomputeForcedFloating(client);
 };
 
 Tile.prototype.onClientKeepBelowChanged = function(client) {
@@ -216,11 +225,11 @@ Tile.prototype.onClientKeepBelowChanged = function(client) {
 };
 
 Tile.prototype.onClientFullScreenChanged = function(client) {
-    this._recomputeForcedFloating();
+    this._recomputeForcedFloating(client);
 };
 
 Tile.prototype.onClientMinimizedChanged = function(client) {
-    this._recomputeForcedFloating();
+    this._recomputeForcedFloating(client);
 };
 
 Tile.prototype.onClientMaximizedStateChanged = function(client) {
diff --git a/contents/code/tilelist.js b/contents/code/tilelist.js
index 5696e41..e4cfe85 100644
--- a/contents/code/tilelist.js
+++ b/contents/code/tilelist.js
@@ -126,6 +126,7 @@ TileList.prototype.addClient = function(client) {
         // If not, create a new tile
         this._addTile(client);
     }
+	client.keepAbove = false;
 };
 
 TileList.prototype.retile = function() {
diff --git a/contents/code/tilingmanager.js b/contents/code/tilingmanager.js
index 3f9c541..60c4b79 100644
--- a/contents/code/tilingmanager.js
+++ b/contents/code/tilingmanager.js
@@ -173,12 +173,11 @@ function TilingManager() {
 						 client.tiling_floating = !client.tiling_floating;
 						 print(client.tiling_floating);
 						 if (client.tiling_floating == true) {
-							 //client.keepAbove = true;
 							 self.tiles._onClientRemoved(client);
+							 client.keepAbove = true;
 						 } else {
 							 //self.tiles._onClientAdded(client);
 							 self.tiles.addClient(client);
-							 //client.keepAbove = false;
 						 }
 						 self.tiles.retile();
 					 });
-- 
GitLab