#! /bin/sh /usr/share/dpatch/dpatch-run
## tray_hotfixes.dpatch, reverting a weird CVS change creating races
##

@DPATCH@
Index: icewm-1.3.7~pre2/src/icetray.cc
===================================================================
--- icewm-1.3.7~pre2.orig/src/icetray.cc	2010-04-28 21:00:30.000000000 +0200
+++ icewm-1.3.7~pre2/src/icetray.cc	2010-04-29 22:11:16.938048246 +0200
@@ -36,14 +36,10 @@
     bool checkMessageEvent(const XClientMessageEvent &message);
     void requestDock();
 
-    void handleUnmap(const XUnmapEvent &ev) {
-        YWindow::handleUnmap(ev);
-        MSG(("hide1"));
-//        if (visible() && ev.window == handle()) {
-            MSG(("hide2"));
+    void handleUnmap(const XUnmapEvent &) {
+        MSG(("hide"));
+        if (visible())
             hide();
-            fManaged = false;
-//        }
     }
 
     void trayChanged();
@@ -51,7 +47,6 @@
     Atom icewm_internal_tray;
     Atom _NET_SYSTEM_TRAY_OPCODE;
     YXTray *fTray2;
-    bool fManaged;
 };
 
 class SysTrayApp: public YXApplication {
@@ -187,7 +182,6 @@
     setSize(fTray2->width(),
             fTray2->height());
     fTray2->show();
-    fManaged = false;
     requestDock();
 }
     
@@ -195,15 +189,10 @@
     fTray2->backgroundChanged();
     setSize(fTray2->width(),
             fTray2->height());
-    if (fTray2->visible()) {
-        if (!fManaged)
-            requestDock();
-        else
-            show();
-    } else {
-        fManaged = false;
+    if (fTray2->visible())
+        show();
+    else 
         hide();
-    }
 }
 
 void SysTray::requestDock() {
@@ -223,19 +212,12 @@
 
         XSendEvent(xapp->display(), w, False, StructureNotifyMask, (XEvent *) &xev);
     }
-    fManaged = true;
 }
 
 bool SysTray::checkMessageEvent(const XClientMessageEvent &message) {
     if (message.message_type == icewm_internal_tray) {
-        MSG(("requestDock %lX", (long)handle()));
-        setSize(fTray2->width(),
-                fTray2->height());
-        MSG(("requestDock2 %d %d", width(), height()));
-        if (fTray2->visible())
-            requestDock();
-        else
-            fManaged = false;
+        MSG(("requestDock"));
+        requestDock();
     }
     return true;
 }
