void AppKbdKeeper::switchToGroup(uint group) { KWindowInfo info = KWindowInfo(KWindowSystem::activeWindow(), 0, NET::WM2WindowClass); QString app = info.windowClassName(); m_mapping[app] = group; m_layout.lockGroup(group); m_info.setCurrentGroup(group); emit changed(); }
//----------------------------------------------------------------------------- // Window added void daisy::windowAdded(WId id) { if (!m_drawerscleared)clearDrawers(); KWindowInfo taskInfo = KWindowSystem::windowInfo( id, NET::WMName | NET::WMVisibleName , NET::WM2WindowClass ); if ( m_alias.indexOf( taskInfo.windowClassName() ) != -1 ) { m_activetasks << m_alias.indexOf( taskInfo.windowClassName() ); if ( m_showindicons )emit update(); } else if ( m_alias.indexOf( QString(taskInfo.windowClassClass().toLower()) ) != -1 ) { m_activetasks << m_alias.indexOf( QString(taskInfo.windowClassClass().toLower()) ); if ( m_showindicons )emit update(); } else if ( m_alias.indexOf( taskInfo.name() ) != -1 ) { m_activetasks << m_alias.indexOf( taskInfo.name() ); if ( m_showindicons )emit update(); } }
void AppKbdKeeper::checkState() { KWindowInfo info = KWindowInfo(KWindowSystem::activeWindow(), 0, NET::WM2WindowClass); QString app = info.windowClassName(); if (!m_mapping.contains(app)) m_mapping.insert(app, 0); m_layout.lockGroup(m_mapping[app]); m_active = app; m_info.setCurrentGroup(m_mapping[app]); emit changed(); }
//----------------------------------------------------------------------------- // Window removed //FIXME void daisy::windowRemoved(WId id) { if (!m_drawerscleared)clearDrawers(); m_closingwindow = -1; KWindowInfo taskInfo = KWindowSystem::windowInfo( id, NET::WMName | NET::WMVisibleName , NET::WM2WindowClass ); if ( m_alias.indexOf( taskInfo.windowClassName() ) != -1 ) { m_closingwindow = m_alias.indexOf( taskInfo.windowClassName() ); if ( m_showindicons )m_up_tmr->setInterval(1500);m_up_tmr->start(); } else if ( m_alias.indexOf( QString(taskInfo.windowClassClass().toLower()) ) != -1 ) { m_closingwindow = m_alias.indexOf( QString(taskInfo.windowClassClass().toLower()) ); if ( m_showindicons )m_up_tmr->setInterval(1500);m_up_tmr->start(); } else if ( m_alias.indexOf( taskInfo.name() ) != -1 ) { m_closingwindow = m_alias.indexOf( taskInfo.name() ); if ( m_showindicons )m_up_tmr->setInterval(1500);m_up_tmr->start(); } else if ( m_alias.indexOf( taskInfo.visibleName() ) != -1 ) { m_closingwindow = m_alias.indexOf( taskInfo.visibleName() ); if ( m_showindicons )m_up_tmr->setInterval(1500);m_up_tmr->start(); } else { getAllTasks(); } if ( m_showindicons )emit update(); }
//----------------------------------------------------------------------------- // Match a task by its name //FIXME WId daisy::matchTask(QString name) { QList<WId> taskDict = KWindowSystem::windows(); QList<WId>::ConstIterator it; for (it = taskDict.begin(); it != taskDict.end(); ++it ) { KWindowInfo taskInfo = KWindowSystem::windowInfo( *it, NET::WMName | NET::WMVisibleName , NET::WM2WindowClass ); if ( name == QString(taskInfo.windowClassName()) || name == QString(taskInfo.windowClassClass().toLower()) ) { return *it; } } return 0; }
void AddRuleMenu::showing() { int x; //dispose previous items // try // { // for (x = 0; x != actions().count(); ++x) // { // delete actions().at(x); // } // } // catch(...) // { // fprintf(stderr, "[AddRuleMenu:%p]: Algorithm `dispose previous items` crashed :(\n"); // } clear(); //populate menu QList<WId> list = KWindowSystem::windows(); int desktop = controller->getIndex(); WId id; KWindowInfo* info; static int window_supported_types = NET::NormalMask | NET::DialogMask | NET::OverrideMask | NET::UtilityMask | NET::DesktopMask | NET::DockMask | NET::TopMenuMask | NET::SplashMask | NET::ToolbarMask | NET::MenuMask; for (x = 0; x != list.count(); ++x) { id = list.at(x); info = new KWindowInfo(id, NET::WMDesktop | NET::WMWindowType, NET::WM2WindowClass); if (info->windowType(window_supported_types) == NET::Normal) if (!desktop || info->desktop() == desktop) addAction(new DesktopRule(this, info->windowClassName(), QIcon(KWindowSystem::icon(id)), info->windowClassName())); } addSeparator(); addAction(new DesktopRule(this, "Always disabled", QIcon(), "*")); addAction(new DesktopRule(this, "Always enabled", QIcon(), "#")); }
//----------------------------------------------------------------------------- // Get task bool daisy::getTaskPtr( QString name ) { QList<WId> taskDict = KWindowSystem::windows(); QList<WId>::ConstIterator it; for (it = taskDict.begin(); it != taskDict.end(); ++it ) { KWindowInfo taskInfo = KWindowSystem::windowInfo( *it, NET::WMName | NET::WMVisibleName, NET::WM2WindowClass ); if ( taskInfo.windowClassName() == name || taskInfo.visibleName() == name || taskInfo.name() == name || QString(taskInfo.windowClassClass().toLower()) == name ) { m_task = TaskManager::TaskManager::self()->findTask( *it ); return true; } } return false; }
//----------------------------------------------------------------------------- // Get all tasks by name //FIXME QList<WId> daisy::matchAllTasks(QString name, int maxtasks) { QList<WId> ret_taskDict; QList<WId> taskDict = KWindowSystem::windows(); QList<WId>::ConstIterator it; for (it = taskDict.begin(); it != taskDict.end(); ++it ) { KWindowInfo taskInfo = KWindowSystem::windowInfo( *it, NET::WMName | NET::WMVisibleName , NET::WM2WindowClass ); if ( name == QString(taskInfo.windowClassName()) || name == QString(taskInfo.windowClassClass().toLower()) ) { if ( maxtasks > ret_taskDict.size() || maxtasks == -1 ) ret_taskDict << *it; else break; } } return ret_taskDict; }
//----------------------------------------------------------------------------- // Get all the tasks //FIXME QList<WId> daisy::getAllTasks() { m_activetasks.clear();m_attentionwindow.clear();showedTasks.clear(); QList<WId> taskDict = KWindowSystem::windows(); m_activewindow = -1;m_startingwindow = -1;m_closingwindow = -1; Plasma::ToolTipContent toolTipData;toolTipData.setAutohide(false); QString str;QString widclass_tmp;total_taskpreviews=0; //THUMBNAILS if ( m_taskpreviews && m_type == QString("standard_dock") ) { for (int i = 0; i < m_max_taskpreviews; ++i) {m_taskicons[i]->setGeometry( QRect(-10000, -10000, 0, 0) );} } if (m_showtooltips_l)clearToolTipContent(); QList<WId>::ConstIterator it; for (it = taskDict.begin(); it != taskDict.end(); ++it ) { KWindowInfo taskInfo = KWindowSystem::windowInfo( *it, NET::WMName | NET::WMVisibleName | NET::WMVisibleIconName | NET::WMState | NET::XAWMState | NET::WMDesktop | NET::WMWindowType, NET::WM2WindowClass ); TaskPtr task_tmp = TaskManager::TaskManager::self()->findTask( *it ); if ( task_tmp && *it == KWindowSystem::activeWindow() ) {m_focusedWindow = *it;} //THUMBNAILS if ( m_taskpreviews && m_type == QString("standard_dock") && task_tmp ) { if ( !m_showtaskoflauncher && ( m_alias.indexOf( taskInfo.windowClassName() ) != -1 || m_alias.indexOf( QString(taskInfo.windowClassClass().toLower()) ) != -1 ) ) {} else if ( total_taskpreviews<m_max_taskpreviews ) { createTaskThumbnail(task_tmp, total_taskpreviews); total_taskpreviews++; showedTasks << *it; } } if ( m_alias.indexOf( taskInfo.windowClassName() ) != -1 || m_alias.indexOf( QString(taskInfo.windowClassClass().toLower()) ) != -1 ) { if ( m_alias.indexOf( taskInfo.windowClassName() ) != -1 ) widclass_tmp = QString( taskInfo.windowClassName() ); else widclass_tmp = QString(taskInfo.windowClassClass().toLower()); //ATTENTION checkAttention( taskInfo, widclass_tmp ); m_activetasks << m_alias.indexOf( widclass_tmp ); if ( *it == KWindowSystem::activeWindow() ) m_activewindow = m_alias.indexOf( widclass_tmp ); //TOLLTIPS if (m_showtooltips_l) { str.clear();QString desk_name = KWindowSystem::desktopName( taskInfo.desktop() ); int win_count = m_activetasks.count( m_alias.indexOf( widclass_tmp ) ); if ( win_count == 1 ) { if (taskInfo.desktop() != -1) {str.append( desk_name );str.insert( 0, i18n("On ") );} else str.insert( 0, i18n("On all desktops") ); toolTipData.setMainText( taskInfo.visibleIconNameWithState() ); toolTipData.setSubText( str ); } else { str.setNum( win_count );str.append( i18n(" instances") ); toolTipData.setMainText( widclass_tmp ); toolTipData.setSubText( str ); } if ( m_tiptype == "thumbnail" ) { #if (KDE_VERSION_MINOR < 3) toolTipData.setWindowToPreview(*it); #else toolTipData.setWindowsToPreview( matchAllTasks( widclass_tmp, 4 ) ); #endif } if ( m_tiptype == "thumbnail" || m_tiptype == "icon" ) toolTipData.setImage( KIcon( m_values[m_alias.indexOf( widclass_tmp )][2]).pixmap(IconSize(KIconLoader::Panel)) ); Plasma::ToolTipManager::self()->setContent(m_widgets[m_alias.indexOf( widclass_tmp )], toolTipData); } } } //THUMBNAILS if ( m_taskpreviews && m_type == QString("standard_dock") ) { resizeRepos( true ); } return taskDict; }
//----------------------------------------------------------------------------- // Window changed //FIXME Signal is emited 4 times? void daisy::windowChanged(WId id, const unsigned long* properties ) { QString widclass_tmp; Plasma::ToolTipContent toolTipData;toolTipData.setAutohide(false); KWindowInfo taskInfo = KWindowSystem::windowInfo( id, NET::WMName | NET::WMVisibleName | NET::WMVisibleIconName | NET::WMState | NET::XAWMState | NET::WMDesktop, NET::WM2WindowClass ); TaskPtr task_tmp = TaskManager::TaskManager::self()->findTask( id ); if ( m_alias.indexOf( taskInfo.windowClassName() ) != -1 || m_alias.indexOf( QString(taskInfo.windowClassClass().toLower()) ) != -1 ) { if ( m_alias.indexOf( taskInfo.windowClassName() ) != -1 ) {widclass_tmp = QString( taskInfo.windowClassName() );} else {widclass_tmp = QString(taskInfo.windowClassClass().toLower());} //ATTENTION checkAttention( taskInfo, widclass_tmp ); if (m_showtooltips_l) { int win_count = m_activetasks.count( m_alias.indexOf( widclass_tmp ) ); QString str;QString desk_name = KWindowSystem::desktopName( taskInfo.desktop() ); if ( win_count == 1 ) { if (taskInfo.desktop() != -1) {str.append( desk_name );str.insert( 0, i18n("On ") );} else str.insert( 0, i18n("On all desktops") ); toolTipData.setMainText( taskInfo.visibleIconNameWithState() ); toolTipData.setSubText( str ); } else { str.setNum( win_count );str.append( i18n(" instances") ); toolTipData.setMainText( widclass_tmp ); toolTipData.setSubText( str ); } if ( m_tiptype == "thumbnail" ) { #if (KDE_VERSION_MINOR < 3) toolTipData.setWindowToPreview(id); #else toolTipData.setWindowsToPreview( matchAllTasks( widclass_tmp, 4 ) ); #endif } if ( m_tiptype == "thumbnail" || m_tiptype == "icon" ) toolTipData.setImage( task_tmp->icon(32, 32, true) ); Plasma::ToolTipManager::self()->setContent(m_widgets[m_alias.indexOf( widclass_tmp )], toolTipData); } if ( m_taskpreviews && m_type == QString("standard_dock") && showedTasks.indexOf( id )!=-1 ) { if (m_showtooltips_l && task_tmp) {Plasma::ToolTipManager::self()->setContent(m_taskicons[showedTasks.indexOf( id )], toolTipData);} if(properties[ NETWinInfo::PROTOCOLS ] & NET::WMIcon) { m_uti_tmr->stop(); m_toupwid = id; m_uti_tmr->start(); } } } }