summaryrefslogtreecommitdiffstats
path: root/kdesktop
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-27 06:25:36 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-09-27 06:25:36 +0000
commit5939318451b18c30ca5838a6993a0ced83ff61e8 (patch)
tree98b6719de8d6736e9f842ba9119f9a48aed26f66 /kdesktop
parent8cc8a98b4054dfdd64cf784cdf52450c9a2c7c50 (diff)
downloadtdebase-5939318451b18c30ca5838a6993a0ced83ff61e8.tar.gz
tdebase-5939318451b18c30ca5838a6993a0ced83ff61e8.zip
Add show desktop get/set commands to DCOP
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1180138 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdesktop')
-rw-r--r--kdesktop/KDesktopIface.h12
-rw-r--r--kdesktop/desktop.cc155
-rw-r--r--kdesktop/desktop.h16
3 files changed, 183 insertions, 0 deletions
diff --git a/kdesktop/KDesktopIface.h b/kdesktop/KDesktopIface.h
index b966405e4..abf98d93b 100644
--- a/kdesktop/KDesktopIface.h
+++ b/kdesktop/KDesktopIface.h
@@ -42,6 +42,18 @@ k_dcop:
*/
virtual void refreshIcons() = 0;
/**
+ * Set show desktop state
+ */
+ virtual void setShowDesktop( bool b ) = 0;
+ /**
+ * @return the show desktop state
+ */
+ virtual bool showDesktopState() = 0;
+ /**
+ * Toggle show desktop state
+ */
+ virtual void toggleShowDesktop() = 0;
+ /**
* @return the urls of selected icons
*/
virtual TQStringList selectedURLs() = 0;
diff --git a/kdesktop/desktop.cc b/kdesktop/desktop.cc
index a05dfcb99..f923d953d 100644
--- a/kdesktop/desktop.cc
+++ b/kdesktop/desktop.cc
@@ -140,6 +140,9 @@ KDesktop::KDesktop( bool x_root_hack, bool wait_for_kded ) :
// those two WStyle_ break kdesktop when the root-hack isn't used (no Dnd)
startup_id( NULL ), m_waitForKicker(0)
{
+ NETRootInfo i( qt_xdisplay(), NET::Supported );
+ m_wmSupport = i.isSupported( NET::WM2ShowingDesktop );
+
m_bWaitForKded = wait_for_kded;
m_miniCli = 0; // created on demand
keys = 0; // created later
@@ -593,6 +596,158 @@ void KDesktop::refreshIcons()
m_pIconView->refreshIcons();
}
+void KDesktop::setShowDesktop( bool b )
+{
+ bool m_showingDesktop = showDesktopState();
+
+ if (b == m_showingDesktop)
+ {
+ return;
+ }
+
+ if( m_wmSupport )
+ {
+ NETRootInfo i( qt_xdisplay(), 0 );
+ i.setShowingDesktop( b );
+ return;
+ }
+
+ if (b)
+ {
+ m_activeWindow = kwinModule()->activeWindow();
+ m_iconifiedList.clear();
+
+ const TQValueList<WId> windows = kwinModule()->windows();
+ for (TQValueList<WId>::ConstIterator it = windows.begin();
+ it != windows.end();
+ ++it)
+ {
+ WId w = *it;
+
+ NETWinInfo info( qt_xdisplay(), w, qt_xrootwin(),
+ NET::XAWMState | NET::WMDesktop );
+
+ if (info.mappingState() == NET::Visible &&
+ (info.desktop() == NETWinInfo::OnAllDesktops ||
+ info.desktop() == (int)kwinModule()->currentDesktop()))
+ {
+ m_iconifiedList.append( w );
+ }
+ }
+
+ // find first, hide later, otherwise transients may get minimized
+ // with the window they're transient for
+ for (TQValueVector<WId>::Iterator it = m_iconifiedList.begin();
+ it != m_iconifiedList.end();
+ ++it)
+ {
+ KWin::iconifyWindow( *it, false );
+ }
+
+ // on desktop changes or when a window is deiconified, we abort the show desktop mode
+ connect(kwinModule(), TQT_SIGNAL(currentDesktopChanged(int)),
+ TQT_SLOT(slotCurrentDesktopChanged(int)));
+ connect(kwinModule(), TQT_SIGNAL(windowChanged(WId,unsigned int)),
+ TQT_SLOT(slotWindowChanged(WId,unsigned int)));
+ connect(kwinModule(), TQT_SIGNAL(windowAdded(WId)),
+ TQT_SLOT(slotWindowAdded(WId)));
+ }
+ else
+ {
+ disconnect(kwinModule(), TQT_SIGNAL(currentDesktopChanged(int)),
+ this, TQT_SLOT(slotCurrentDesktopChanged(int)));
+ disconnect(kwinModule(), TQT_SIGNAL(windowChanged(WId,unsigned int)),
+ this, TQT_SLOT(slotWindowChanged(WId,unsigned int)));
+ disconnect(kwinModule(), TQT_SIGNAL(windowAdded(WId)),
+ this, TQT_SLOT(slotWindowAdded(WId)));
+
+ for (TQValueVector<WId>::ConstIterator it = m_iconifiedList.begin();
+ it != m_iconifiedList.end();
+ ++it)
+ {
+ KWin::deIconifyWindow(*it, false);
+ }
+
+ KWin::forceActiveWindow(m_activeWindow);
+ }
+
+ m_showingDesktop = b;
+ emit desktopShown(m_showingDesktop);
+}
+
+void KDesktop::slotCurrentDesktopChanged(int)
+{
+ setShowDesktop( false );
+}
+
+void KDesktop::slotWindowAdded(WId w)
+{
+ bool m_showingDesktop = showDesktopState();
+
+ if (!m_showingDesktop)
+ {
+ return;
+ }
+
+ NETWinInfo inf(qt_xdisplay(), w, qt_xrootwin(),
+ NET::XAWMState | NET::WMWindowType);
+ NET::WindowType windowType = inf.windowType(NET::AllTypesMask);
+
+ if ((windowType == NET::Normal || windowType == NET::Unknown) &&
+ inf.mappingState() == NET::Visible)
+ {
+ KConfig kwincfg( "kwinrc", true ); // see in kwin
+ kwincfg.setGroup( "Windows" );
+ if( kwincfg.readBoolEntry( "ShowDesktopIsMinimizeAll", false ))
+ {
+ m_iconifiedList.clear();
+ m_showingDesktop = false;
+ emit desktopShown(false);
+ }
+ else
+ {
+ m_activeWindow = w;
+ setShowDesktop(false);
+ }
+ }
+}
+
+void KDesktop::slotWindowChanged(WId w, unsigned int dirty)
+{
+ bool m_showingDesktop = showDesktopState();
+
+ if (!m_showingDesktop)
+ {
+ return;
+ }
+
+ if (dirty & NET::XAWMState)
+ {
+ NETWinInfo inf(qt_xdisplay(), w, qt_xrootwin(),
+ NET::XAWMState | NET::WMWindowType);
+ NET::WindowType windowType = inf.windowType(NET::AllTypesMask);
+
+ if ((windowType == NET::Normal || windowType == NET::Unknown) &&
+ inf.mappingState() == NET::Visible)
+ {
+ // a window was deiconified, abort the show desktop mode.
+ m_iconifiedList.clear();
+ m_showingDesktop = false;
+ emit desktopShown(false);
+ }
+ }
+}
+
+bool KDesktop::showDesktopState()
+{
+ return kwinModule()->showingDesktop();
+}
+
+void KDesktop::toggleShowDesktop()
+{
+ setShowDesktop(!showDesktopState());
+}
+
KActionCollection * KDesktop::actionCollection()
{
if (!m_pIconView)
diff --git a/kdesktop/desktop.h b/kdesktop/desktop.h
index 31928e9d4..19cc4cbbe 100644
--- a/kdesktop/desktop.h
+++ b/kdesktop/desktop.h
@@ -24,6 +24,7 @@
#include <tqwidget.h>
#include <tqstringlist.h>
+#include <tqvaluevector.h>
#include <kapplication.h> // for logout parameters
@@ -75,6 +76,9 @@ public:
virtual void selectAll();
virtual void unselectAll();
virtual void refreshIcons();
+ virtual void setShowDesktop( bool b );
+ virtual bool showDesktopState();
+ virtual void toggleShowDesktop();
virtual TQStringList selectedURLs();
virtual void configure();
@@ -151,6 +155,11 @@ private slots:
// when there seems to be no kicker, we have to get desktopIconsArea from kwinModule
void slotNoKicker();
+ /** Used for desktop show/hide functionality */
+ void slotCurrentDesktopChanged(int);
+ void slotWindowAdded(WId w);
+ void slotWindowChanged(WId w, unsigned int dirty);
+
protected:
void initConfig();
void initRoot();
@@ -172,6 +181,9 @@ protected:
private slots:
void desktopResized();
+signals:
+ void desktopShown(bool shown);
+
private:
KGlobalAccel *keys;
@@ -212,6 +224,10 @@ private:
/** Possible values for "kdesktoprc"->"Mouse Buttons"->"WheelDirection" */
static const char* m_wheelDirectionStrings[2];
+
+ bool m_wmSupport;
+ WId m_activeWindow;
+ TQValueVector<WId> m_iconifiedList;
};
#endif