summaryrefslogtreecommitdiffstats
path: root/kdesktop/desktop.cc
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/desktop.cc
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/desktop.cc')
-rw-r--r--kdesktop/desktop.cc155
1 files changed, 155 insertions, 0 deletions
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)