From 222d8cd7e9c0f28b3dd0b9b253a0b096d856195f Mon Sep 17 00:00:00 2001
From: markt <markt>
Date: Fri, 8 Jun 2007 19:39:12 +0000
Subject: don't tab transient windows from apps file, and change their layers
 when the main window does

---
 ChangeLog        |  4 ++++
 src/Remember.cc  |  6 ++++--
 src/WinClient.cc | 17 ++++++-----------
 src/Window.cc    | 42 ++++++++++++++++++++++++++++++++----------
 4 files changed, 46 insertions(+), 23 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 07a09d7..a638414 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
  (Format: Year/Month/Day)
 Changes for 1.0.0:
+*07/06/08:
+   * Fix transient windows getting tabbed from apps file and not changing layers
+     when main window is in a lowered tab (Mark)
+     WinClient.cc Window.cc Remember.cc
 *07/06/06:
    * Fix to avoid rogue instances of /bin/sh after forking away programs (Mathias)
      util/fbrun/FbRun.cc src/FbCommands.cc
diff --git a/src/Remember.cc b/src/Remember.cc
index e0a7b0f..55816c4 100644
--- a/src/Remember.cc
+++ b/src/Remember.cc
@@ -1132,8 +1132,10 @@ void Remember::setupFrame(FluxboxWindow &win) {
 
 void Remember::setupClient(WinClient &winclient) {
 
-    if (winclient.screen().isRestart())
-        return; // don't mess up windows on restart
+    // leave windows alone on restart
+    // don't apply settings to transient windows
+    if (winclient.screen().isRestart() || winclient.transientFor())
+        return;
 
     Application *app = find(winclient);
     if (app == 0)
diff --git a/src/WinClient.cc b/src/WinClient.cc
index b7e14e9..bb6bf10 100644
--- a/src/WinClient.cc
+++ b/src/WinClient.cc
@@ -107,6 +107,11 @@ WinClient::WinClient(Window win, BScreen &screen, FluxboxWindow *fbwin):FbTk::Fb
         // clear transient waiting list for this window
         s_transient_wait.erase(win);
     }
+
+    // also check if this window is a transient
+    // this needs to be done before creating an fbwindow, so this doesn't get
+    // tabbed using the apps file
+    updateTransientInfo();
 }
 
 WinClient::~WinClient() {
@@ -263,13 +268,6 @@ void WinClient::updateWMClassHint() {
 }
 
 void WinClient::updateTransientInfo() {
-#ifdef DEBUG
-    cerr<<__FUNCTION__<<": m_win = "<<m_win<<endl;
-#endif // DEBUG
-    if (m_win == 0)
-        return;
-
-
     // remove this from parent
     if (transientFor() != 0) {
         transientFor()->transientList().remove(this);
@@ -293,7 +291,7 @@ void WinClient::updateTransientInfo() {
         return;
     }
 
-    if (win != None && m_win->screen().rootWindow() == win) {
+    if (win != None && screen().rootWindow() == win) {
         // transient for root window... =  transient for group
         // I don't think we are group-aware yet
         return;
@@ -334,9 +332,6 @@ void WinClient::updateTransientInfo() {
         // we need to add ourself to the right client in
         // the transientFor() window so we search client
         transient_for->transientList().push_back(this);
-
-        if (transientFor()->fbwindow() && transientFor()->fbwindow()->isStuck())
-            m_win->stick();
     }
 
 }
diff --git a/src/Window.cc b/src/Window.cc
index 46530b7..23e11bf 100644
--- a/src/Window.cc
+++ b/src/Window.cc
@@ -424,8 +424,9 @@ void FluxboxWindow::init() {
     /* Read state above here, apply state below here. */
     /**************************************************/
 
-    // update transient infomation
-    m_client->updateTransientInfo();
+    if (m_client->transientFor() && m_client->transientFor()->fbwindow() &&
+        m_client->transientFor()->fbwindow()->isStuck())
+        stick();
 
     // adjust the window decorations based on transience and window sizes
     if (m_client->isTransient() && !screen().decorateTransient()) {
@@ -1831,6 +1832,19 @@ void FluxboxWindow::stick() {
         m_workspacesig.notify();
     }
 
+    ClientList::iterator client_it = clientList().begin();
+    ClientList::iterator client_it_end = clientList().end();
+    for (; client_it != client_it_end; ++client_it) {
+
+        WinClient::TransientList::const_iterator it = (*client_it)->transientList().begin();
+        WinClient::TransientList::const_iterator it_end = (*client_it)->transientList().end();
+        for (; it != it_end; ++it) {
+            if ((*it)->fbwindow() && (*it)->fbwindow()->isStuck() != stuck)
+                (*it)->fbwindow()->stick();
+        }
+
+    }
+
 }
 
 
@@ -1939,16 +1953,24 @@ void FluxboxWindow::moveToLayer(int layernum, bool force) {
     layernum = win->layerItem().getLayerNum();
     win->setLayerNum(layernum);
 
-    WinClient::TransientList::const_iterator it = client->transientList().begin();
-    WinClient::TransientList::const_iterator it_end = client->transientList().end();
-    for (; it != it_end; ++it) {
-        win = (*it)->fbwindow();
-        if (win && !win->isIconic()) {
-            screen().updateNetizenWindowRaise((*it)->window());
-            win->layerItem().moveToLayer(layernum);
-            win->setLayerNum(layernum);
+    // move all the transients, too
+    ClientList::iterator client_it = win->clientList().begin();
+    ClientList::iterator client_it_end = win->clientList().end();
+    for (; client_it != client_it_end; ++client_it) {
+
+        WinClient::TransientList::const_iterator it = (*client_it)->transientList().begin();
+        WinClient::TransientList::const_iterator it_end = (*client_it)->transientList().end();
+        for (; it != it_end; ++it) {
+            FluxboxWindow *fbwin = (*it)->fbwindow();
+            if (fbwin && !fbwin->isIconic()) {
+                screen().updateNetizenWindowRaise((*it)->window());
+                fbwin->layerItem().moveToLayer(layernum);
+                fbwin->setLayerNum(layernum);
+            }
         }
+
     }
+
 }
 
 void FluxboxWindow::setFocusHidden(bool value) {
-- 
cgit v0.11.2