KPager::KPager(KPagerMainWindow *parent, const char *name) : QFrame (parent, name, WStyle_Customize | WStyle_NoBorder | WStyle_Tool) , m_layout(0) , m_mnu(0) , m_smnu(0) , m_dmnu(0) { m_windows.setAutoDelete(true); // delete windows info after removal setBackgroundColor( black ); m_winmodule=new KWinModule(this); m_currentDesktop=m_winmodule->currentDesktop(); m_grabWinTimer=new QTimer(this,"grabWinTimer"); connect(m_grabWinTimer, SIGNAL(timeout()), this, SLOT(slotGrabWindows())); KPagerConfigDialog::initConfiguration(); KConfig *cfg = kapp->config(); cfg->setGroup("KPager"); m_showStickyOption=cfg->readBoolEntry("ShowStickyOption",false); int numberOfDesktops=m_winmodule->numberOfDesktops(); for (int i=0;i<numberOfDesktops;i++) { Desktop *dsk=new Desktop(i+1,m_winmodule->desktopName(i),this); m_desktops.append(dsk); } m_layoutType=static_cast<enum KPager::LayoutTypes>( KPagerConfigDialog::m_layoutType ); connect( m_winmodule, SIGNAL( activeWindowChanged(WId)), SLOT(slotActiveWindowChanged(WId))); connect( m_winmodule, SIGNAL( windowAdded(WId) ), SLOT( slotWindowAdded(WId) ) ); connect( m_winmodule, SIGNAL( windowRemoved(WId) ), SLOT( slotWindowRemoved(WId) ) ); connect( m_winmodule, SIGNAL( windowChanged(WId,unsigned int) ), SLOT( slotWindowChanged(WId,unsigned int) ) ); connect( m_winmodule, SIGNAL( stackingOrderChanged() ), SLOT( slotStackingOrderChanged() ) ); connect( m_winmodule, SIGNAL( desktopNamesChanged() ), SLOT( slotDesktopNamesChanged() ) ); connect( m_winmodule, SIGNAL( numberOfDesktopsChanged(int) ), SLOT( slotNumberOfDesktopsChanged(int) ) ); connect( m_winmodule, SIGNAL( currentDesktopChanged(int)), SLOT( slotCurrentDesktopChanged(int) ) ); connect(kapp, SIGNAL(backgroundChanged(int)), SLOT(slotBackgroundChanged(int))); QFont defFont(KGlobalSettings::generalFont().family(), 10, QFont::Bold); defFont = cfg->readFontEntry("Font", &defFont); setFont(defFont); m_prefs_action = KStdAction::preferences(this, SLOT(configureDialog()), parent->actionCollection()); m_quit_action = KStdAction::quit(kapp, SLOT(quit()), parent->actionCollection()); updateLayout(); }
void ShowDesktop::showDesktop( bool b ) { if (b == m_showingDesktop) { return; } if( m_wmSupport ) { NETRootInfo i( tqt_xdisplay(), 0 ); i.setShowingDesktop( b ); return; } if (b) { m_activeWindow = Kicker::the()->twinModule()->activeWindow(); m_iconifiedList.clear(); const TQValueList<WId> windows = Kicker::the()->twinModule()->windows(); for (TQValueList<WId>::ConstIterator it = windows.begin(); it != windows.end(); ++it) { WId w = *it; NETWinInfo info( tqt_xdisplay(), w, tqt_xrootwin(), NET::XAWMState | NET::WMDesktop ); if (info.mappingState() == NET::Visible && (info.desktop() == NETWinInfo::OnAllDesktops || info.desktop() == (int)Kicker::the()->twinModule()->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(Kicker::the()->twinModule(), TQT_SIGNAL(currentDesktopChanged(int)), TQT_SLOT(slotCurrentDesktopChanged(int))); connect(Kicker::the()->twinModule(), TQT_SIGNAL(windowChanged(WId,unsigned int)), TQT_SLOT(slotWindowChanged(WId,unsigned int))); connect(Kicker::the()->twinModule(), TQT_SIGNAL(windowAdded(WId)), TQT_SLOT(slotWindowAdded(WId))); } else { disconnect(Kicker::the()->twinModule(), TQT_SIGNAL(currentDesktopChanged(int)), this, TQT_SLOT(slotCurrentDesktopChanged(int))); disconnect(Kicker::the()->twinModule(), TQT_SIGNAL(windowChanged(WId,unsigned int)), this, TQT_SLOT(slotWindowChanged(WId,unsigned int))); disconnect(Kicker::the()->twinModule(), 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 ShowDesktop::showDesktop( bool b ) { if (b == m_showingDesktop) { return; } if( m_wmSupport ) { NETRootInfo i( QX11Info::display(), 0 ); i.setShowingDesktop( b ); return; } if (b) { m_activeWindow = KWindowSystem::activeWindow(); m_iconifiedList.clear(); const QList<WId> windows = KWindowSystem::windows(); QList<WId>::const_iterator itEnd = windows.constEnd(); for (QList<WId>::const_iterator it = windows.constBegin(); it != itEnd; ++it) { WId w = *it; NETWinInfo info( QX11Info::display(), w, QX11Info::appRootWindow(), NET::XAWMState | NET::WMDesktop ); if (info.mappingState() == NET::Visible && (info.desktop() == NETWinInfo::OnAllDesktops || info.desktop() == (int)KWindowSystem::currentDesktop())) { m_iconifiedList.append( w ); } } // find first, hide later, otherwise transients may get minimized // with the window they're transient for QVector<WId>::iterator itEnd2 = m_iconifiedList.end(); for (QVector<WId>::iterator it = m_iconifiedList.begin(); it != itEnd2; ++it) { KWindowSystem::minimizeWindow( *it, false ); } // on desktop changes or when a window is deiconified, we abort the show desktop mode connect(KWindowSystem::self(), SIGNAL(currentDesktopChanged(int)), SLOT(slotCurrentDesktopChanged(int))); connect(KWindowSystem::self(), SIGNAL(windowChanged(WId,unsigned int)), SLOT(slotWindowChanged(WId,unsigned int))); connect(KWindowSystem::self(), SIGNAL(windowAdded(WId)), SLOT(slotWindowAdded(WId))); } else { disconnect(KWindowSystem::self(), SIGNAL(currentDesktopChanged(int)), this, SLOT(slotCurrentDesktopChanged(int))); disconnect(KWindowSystem::self(), SIGNAL(windowChanged(WId,unsigned int)), this, SLOT(slotWindowChanged(WId,unsigned int))); disconnect(KWindowSystem::self(), SIGNAL(windowAdded(WId)), this, SLOT(slotWindowAdded(WId))); QVector<WId>::const_iterator itEnd = m_iconifiedList.constEnd(); for (QVector<WId>::const_iterator it = m_iconifiedList.constBegin(); it != itEnd; ++it) { KWindowSystem::unminimizeWindow(*it, false); } KWindowSystem::forceActiveWindow(m_activeWindow); } m_showingDesktop = b; emit desktopShown(m_showingDesktop); }