Branch: master

80aec91d 2014-12-01 02:25:47 Timothy Pearson
Fix broken task switching when transparency enabled
This resolves Bug 2220
M client/myrootpixmap.cc
M client/myrootpixmap.h
diff --git a/client/myrootpixmap.cc b/client/myrootpixmap.cc
index 11d5eb9..999ecf4 100644
--- a/client/myrootpixmap.cc
+++ b/client/myrootpixmap.cc
@@ -22,7 +22,7 @@
 #include <tdeapplication.h>
 #include <kimageeffect.h>
 #include <kpixmapio.h>
-#include <twinmodule.h>
+#include <netwm.h>
 #include <twin.h>
 #include <kdebug.h>
 #include <netwm.h>
@@ -38,11 +38,37 @@
     return DCOPRef("kdesktop", "KBackgroundIface").call("currentWallpaper", desktop);
 }
 
+DesktopWallpaperWatcher::DesktopWallpaperWatcher() : TQWidget(), m_old_current_desktop(-1)
+{
+	kapp->installX11EventFilter( this );
+	(void ) kapp->desktop(); //trigger desktop widget creation to select root window events
+}
+
+DesktopWallpaperWatcher::~DesktopWallpaperWatcher()
+{
+}
+
+bool DesktopWallpaperWatcher::x11Event( XEvent * ev )
+{
+	if ( ev->xany.window == tqt_xrootwin() ) {
+		NETRootInfo rinfo( tqt_xdisplay(), NET::CurrentDesktop );
+		rinfo.activate();
+
+		if ( rinfo.currentDesktop() != m_old_current_desktop ) {
+			emit currentDesktopChanged( rinfo.currentDesktop() );
+		}
+
+		m_old_current_desktop = rinfo.currentDesktop();
+	}
+
+	return false;
+}
+
 class KMyRootPixmapData
 {
 public:
 #ifdef Q_WS_X11
-    KWinModule *twin;
+    DesktopWallpaperWatcher *twin;
 #endif
 };
 
@@ -74,7 +100,7 @@
 //    connect(m_pTimer, TQT_SIGNAL(timeout()), TQT_SLOT(repaint()));
 
 #ifdef Q_WS_X11
-    d->twin = new KWinModule( this );
+    d->twin = new DesktopWallpaperWatcher();
     connect(d->twin, TQT_SIGNAL(currentDesktopChanged(int)), TQT_SLOT(desktopChanged(int)));
 #endif
 
@@ -228,5 +254,5 @@
     }
 }
 
-// #include "krootpixmap.moc"
+#include "myrootpixmap.moc"
 #endif
diff --git a/client/myrootpixmap.h b/client/myrootpixmap.h
index 26ebc9c..7d8f0e8 100644
--- a/client/myrootpixmap.h
+++ b/client/myrootpixmap.h
@@ -25,10 +25,26 @@
 class TDESharedPixmap;
 class KMyRootPixmapData;
 
+class DesktopWallpaperWatcher : public TQWidget
+{
+	Q_OBJECT
+
+	public:
+		DesktopWallpaperWatcher();
+		~DesktopWallpaperWatcher();
+
+		bool x11Event( XEvent * ev );
+
+	signals:
+		void currentDesktopChanged( int desktop);
+
+	private:
+		int m_old_current_desktop;
+};
+
 class KMyRootPixmap: public TQObject
 {
     Q_OBJECT
-  
 
 public:
     KMyRootPixmap( TQWidget *target=NULL, const char *name=0 );
@@ -91,7 +107,7 @@
 //    TQWidget *m_pWidget;
 //    TQTimer *m_pTimer;
     TDESharedPixmap *m_pPixmap;
-   KMyRootPixmapData *d;
+    KMyRootPixmapData *d;
 
     void init();
 };