From a69b117fe4a2abb4eaeb70b41a98b0561912472c Mon Sep 17 00:00:00 2001
From: rathnor <rathnor>
Date: Fri, 27 Jun 2003 15:05:19 +0000
Subject: fix slit netizen issues

---
 ChangeLog        |  3 +++
 src/Screen.cc    |  8 +++-----
 src/Slit.cc      | 30 ++++++++++++++++++++++++------
 src/WinClient.cc |  4 +++-
 4 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index badc7a2..da7a447 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 (Format: Year/Month/Day)
 Changes for 0.9.4:
+*03/06/28:
+   * Fix slit netizens (e.g. withdrawn pager)  (Simon)
+     Slit.cc WinClient.cc Screen.cc
 *03/06/26:
    * Speedups for having many (particularly stuck) windows (Simon)
      Toolbar.hh/cc IconBar.hh/cc ToolbarHandler.cc Gnome.cc Window.cc
diff --git a/src/Screen.cc b/src/Screen.cc
index b2d0190..eee6f2d 100644
--- a/src/Screen.cc
+++ b/src/Screen.cc
@@ -22,7 +22,7 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: Screen.cc,v 1.195 2003/06/25 05:47:23 fluxgen Exp $
+// $Id: Screen.cc,v 1.196 2003/06/27 15:05:19 rathnor Exp $
 
 
 #include "Screen.hh"
@@ -1034,13 +1034,11 @@ void BScreen::updateNetizenConfigNotify(XEvent &e) {
 FluxboxWindow *BScreen::createWindow(Window client) {
     WinClient *winclient = new WinClient(client, *this);
 
+    if (winclient->initial_state == WithdrawnState) {
+        delete winclient;
 #ifdef SLIT
-    if (winclient->initial_state == WithdrawnState)
         slit()->addClient(client);
-
 #endif // SLIT
-    if (winclient->initial_state == WithdrawnState) {
-        delete winclient;
         return 0;
     }
 
diff --git a/src/Slit.cc b/src/Slit.cc
index b135303..cef7448 100644
--- a/src/Slit.cc
+++ b/src/Slit.cc
@@ -22,7 +22,7 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: Slit.cc,v 1.68 2003/06/24 20:19:36 fluxgen Exp $
+// $Id: Slit.cc,v 1.69 2003/06/27 15:05:19 rathnor Exp $
 
 #include "Slit.hh"
 
@@ -56,6 +56,7 @@
 #include "SlitTheme.hh"
 #include "SlitClient.hh"
 #include "Xutil.hh"
+#include "FbAtoms.hh"
 
 #include <algorithm>
 #include <iostream>
@@ -67,6 +68,7 @@
 #endif // HAVE_SYS_STAT_H
 
 #include <X11/Xatom.h>
+#include <X11/Xlib.h>
 
 #include <iostream>
 #include <algorithm>
@@ -452,12 +454,28 @@ void Slit::addClient(Window w) {
             client->setWindow(client->clientWindow());
         }
 
-        XFree(wmhints);
+        XFree((void *) wmhints);
     } else {
         client->setIconWindow(None);
         client->setWindow(client->clientWindow());
     }
 
+    Atom *proto = 0;
+    int num_return = 0;
+    FbAtoms *fbatoms = FbAtoms::instance();
+
+    if (XGetWMProtocols(disp, w, &proto, &num_return)) {
+        
+        for (int i = 0; i < num_return; ++i) {
+            if (proto[i] == fbatoms->getFluxboxStructureMessagesAtom())
+                screen().addNetizen(w);
+        }
+        
+        XFree((void *) proto);
+    } else {
+        cerr<<"Warning: Failed to read WM Protocols. "<<endl;
+    }
+
     XWindowAttributes attrib;
     
 #ifdef KDE
@@ -476,7 +494,7 @@ void Slit::addClient(Window w) {
                            &ajunk, &ijunk, &uljunk, &uljunk,
                            (unsigned char **) &data) == Success && data) {
         iskdedockapp = (data && data[0] != 0);
-        XFree((char *) data);
+        XFree((void *) data);
         data = 0;
     }
 
@@ -488,7 +506,7 @@ void Slit::addClient(Window w) {
                                &ajunk, &ijunk, &uljunk, &uljunk,
                                (unsigned char **) &data) == Success && data) {
             iskdedockapp = (data && data[0] != 0);
-            XFree((char *) data);
+            XFree((void *) data);
             data = 0;
         }
     }
@@ -964,7 +982,7 @@ void Slit::handleEvent(XEvent &event) {
 					
             if (data)
                 iskdedockapp = True;
-            XFree((char *) data);
+            XFree((void *) data);
             data = 0;
         }
 
@@ -975,7 +993,7 @@ void Slit::handleEvent(XEvent &event) {
                                    m_kwm1_dockwindow, &ajunk, &ijunk, &uljunk,
                                    &uljunk, (unsigned char **) &data) == Success && data) {
                 iskdedockapp = (data && data[0] != 0);
-                XFree((char *) data);
+                XFree((void *) data);
                 data = 0;
             }
         }
diff --git a/src/WinClient.cc b/src/WinClient.cc
index ddc0c57..4b13487 100644
--- a/src/WinClient.cc
+++ b/src/WinClient.cc
@@ -19,7 +19,7 @@
 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 // DEALINGS IN THE SOFTWARE.
 
-// $Id: WinClient.cc,v 1.15 2003/06/24 12:58:57 rathnor Exp $
+// $Id: WinClient.cc,v 1.16 2003/06/27 15:05:19 rathnor Exp $
 
 #include "WinClient.hh"
 
@@ -96,6 +96,8 @@ WinClient::~WinClient() {
         transients.pop_back();
     }
 
+    screen().removeNetizen(window());
+
     if (window_group != 0) {
         fluxbox->removeGroupSearch(window_group);
         window_group = 0;
-- 
cgit v0.11.2