From 80aec91d21bf675286b1a0869eeba19f9847e3ec Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Mon, 1 Dec 2014 02:25:47 -0600 Subject: [PATCH] Fix broken task switching when transparency enabled This resolves Bug 2220 --- client/myrootpixmap.cc | 34 ++++++++++++++++++++++++++++++---- client/myrootpixmap.h | 20 ++++++++++++++++++-- 2 files changed, 48 insertions(+), 6 deletions(-) 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 #include #include -#include +#include #include #include #include @@ -38,11 +38,37 @@ static TQString wallpaperForDesktop(int desktop) 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 @@ void KMyRootPixmap::init() // 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 @@ void KMyRootPixmap::updateBackground( TDESharedPixmap *spm ) } } -// #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 TQTimer; 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 @@ private: // TQWidget *m_pWidget; // TQTimer *m_pTimer; TDESharedPixmap *m_pPixmap; - KMyRootPixmapData *d; + KMyRootPixmapData *d; void init(); };