// Scroll tasks void daisy::scrollTasks(int delta) { WId widstore_tmp = 0;WId wid_tmp = 0; QList<WId> real_taskDict;QList<WId> taskDict = KWindowSystem::windows();QList<WId>::ConstIterator it; KWindowInfo taskInfo = KWindowSystem::windowInfo( m_focusedWindow, NET::WMState, NET::WM2WindowClass ); for (it = taskDict.begin(); it != taskDict.end(); ++it ) { TaskPtr task_tmp = TaskManager::TaskManager::self()->findTask( *it ); if ( task_tmp ){real_taskDict << *it;} } if (real_taskDict.size() > 0) { if ( real_taskDict.indexOf( KWindowSystem::activeWindow() ) != -1 ){widstore_tmp = KWindowSystem::activeWindow();} else{widstore_tmp = m_focusedWindow;} { if (delta >0) { if (real_taskDict.indexOf( widstore_tmp ) < real_taskDict.size()-1 ){wid_tmp = real_taskDict[real_taskDict.indexOf( widstore_tmp )+1];} else{wid_tmp = real_taskDict[0];} } else { if (real_taskDict.indexOf( widstore_tmp ) > 0 ){wid_tmp = real_taskDict[real_taskDict.indexOf( widstore_tmp )-1];} else{wid_tmp = real_taskDict[real_taskDict.size()-1];} } if (real_taskDict.size() == 1) { taskInfo = KWindowSystem::windowInfo( wid_tmp, NET::WMState, NET::WM2WindowClass ); if ( !taskInfo.isMinimized() )KWindowSystem::minimizeWindow( wid_tmp, true ); else focusTask(wid_tmp); } else focusTask(wid_tmp); } } }
bool RKWardApplication::x11EventFilter (XEvent *e) { if (detect_x11_creations) { if (e->type == CreateNotify) { if (e->xcreatewindow.parent == QX11Info::appRootWindow ()) { KWindowInfo info = KWindowInfo (e->xcreatewindow.window, NET::WMName | NET::WMWindowType); // at this point, we used to check, whether this window has some name or another. This heuristic allowed to sieve out helper windows of the window manager. However, since R 2.8.0, sometimes the window is mapped, before it has been given a name. // Now we rely on the fact (we hope it *is* a fact), that the device window is always the first one created. if ((info.windowType (0xFFFF) != 0) && (!created_window)) { created_window = e->xcreatewindow.window; return true; } } else { RK_ASSERT (false); } } } if (e->type == PropertyNotify) { if (e->xproperty.atom == wm_name_property) { if (name_watchers_list.contains (e->xproperty.window)) { KWindowInfo wininfo = KWindowInfo (e->xproperty.window, NET::WMName); name_watchers_list[e->xproperty.window]->setCaption (wininfo.name ()); return true; } } } return KApplication::x11EventFilter (e); }
void Notification::mouseReleaseEvent(QMouseEvent * event) { // qDebug() << "CLICKED" << event; QString appName; QString windowTitle; if (m_actionWidget && m_actionWidget->hasDefaultAction()) { emit actionTriggered(m_actionWidget->defaultAction()); return; } for (WId i : KWindowSystem::stackingOrder()) { KWindowInfo info = KWindowInfo(i, NET::WMName | NET::WMVisibleName); appName = info.name(); windowTitle = info.visibleName(); // qDebug() << " " << i << "APPNAME" << appName << "TITLE" << windowTitle; if (appName.isEmpty()) { QWidget::mouseReleaseEvent(event); return; } if (appName == appLabel->text() || windowTitle == appLabel->text()) { KWindowSystem::raiseWindow(i); closeButton_clicked(); return; } } }
//----------------------------------------------------------------------------- // Elaborate Tasks Menu void daisy::elabTaskMenu( QList<WId> taskDict, int clickedlaunch_tmp ) { delete m_task_menu; m_task_menu = new KMenu(); taskDrawers.clear(); QList<WId>::ConstIterator it; for (it = taskDict.begin(); it != taskDict.end(); ++it ) { KWindowInfo taskInfo = KWindowSystem::windowInfo( *it, NET::WMName | NET::WMVisibleName | NET::WMWindowType | NET::WMVisibleIconName , NET::WM2StartupId | NET::WM2WindowClass | NET::WM2WindowRole ); QString visiconame_tmp = taskInfo.visibleIconName(); QString visname_tmp = taskInfo.visibleName(); QString iconame_tmp = m_values[clickedlaunch_tmp][2]; m_act_1 = new QAction(KIcon(iconame_tmp), visiconame_tmp, this); connect(m_act_1, SIGNAL(triggered(bool)), this, SLOT(taskMenuClicked())); m_task_menu->addAction ( m_act_1 ); taskDrawers << *it; } m_task_menu->exec( QCursor::pos() ); }
void KWindowInfo::showMessage( QWidget *window, const QString &text, int timeout ) { KWindowInfo *info = new KWindowInfo( window ); info->autoDel = true; info->message( text, timeout ); if ( timeout == 0 ) delete info; }
//----------------------------------------------------------------------------- // Close task //FIXME void daisy::closeTask(WId id) { KWindowInfo taskInfo = KWindowSystem::windowInfo( id, NET::WMState ); if ( taskInfo.valid() ) { NETRootInfo ri( QX11Info::display(), NET::CloseWindow ); ri.closeWindowRequest( id ); } }
//----------------------------------------------------------------------------- // Focus task //FIXME void daisy::focusTask(WId id) { KWindowInfo taskInfo = KWindowSystem::windowInfo( id, NET::WMState, NET::WM2WindowClass ); if ( taskInfo.valid() ) { KWindowSystem::unminimizeWindow( id, true ); KWindowSystem::activateWindow( id ); } }
void WindowListModel::onWindowAdded(WId id) { KWindowInfo kwi = KWindowSystem::self()->windowInfo(id, NET::WMName | NET::WMVisibleName | NET::WMVisibleIconName | NET::WMWindowType); if( ( kwi.windowType(NET::NormalMask) == NET::Normal ) && ( id != m_kdevWinId ) ) { beginInsertRows( QModelIndex(), m_winList.count(), m_winList.count() + 1 ); m_winList.append( kwi ); // qDebug() << "onWindowAdded " << kwi.visibleName() << "(" << id << ")"; endInsertRows(); } }
void GraphicalUi::hideMainWidget() { #if defined(HAVE_KDE4) && defined(Q_WS_X11) KWindowInfo info = KWindowSystem::windowInfo(mainWidget()->winId(), NET::WMDesktop | NET::WMFrameExtents); _onAllDesktops = info.onAllDesktops(); #endif if (instance()->isHidingMainWidgetAllowed()) mainWidget()->hide(); }
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(); }
void TitleWidget::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { Plasma::IconWidget::mouseMoveEvent(event); if (m_drag && (event->buttons() & Qt::LeftButton)) { WId wid = KWindowSystem::activeWindow(); if (wid) { XUngrabPointer(QX11Info::display(), QX11Info::appTime()); NETRootInfo rootInfo(QX11Info::display(), NET::WMMoveResize); KWindowInfo info = KWindowSystem::windowInfo(wid, NET::WMGeometry); int x; int y; QPointF p = event->screenPos(); if (p.x() > info.geometry().x() && p.x() < info.geometry().x() + info.geometry().width()) x = p.x(); else x = info.geometry().x(); if (p.y() > info.geometry().y() && p.y() < info.geometry().y() + info.geometry().height()) y = p.y(); else y = info.geometry().y(); rootInfo.moveResizeRequest( wid, x, y, NET::Move); } } }
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(); }
void SwitchWindow::wheelEvent(QGraphicsSceneWheelEvent *event) { //TODO somehow find the "next" or "previous" window //without changing hte window order (don't want to always go between two windows) if (m_windowsOrder.isEmpty()) { m_windowsOrder = KWindowSystem::stackingOrder(); } else { if (!m_clearOrderTimer) { m_clearOrderTimer = new QTimer(this); connect(m_clearOrderTimer, SIGNAL(timeout()), this, SLOT(clearWindowsOrder())); m_clearOrderTimer->setSingleShot(true); m_clearOrderTimer->setInterval(1000); } m_clearOrderTimer->start(); } const WId activeWindow = KWindowSystem::activeWindow(); const bool up = event->delta() > 0; bool next = false; WId first = 0; WId last = 0; for (int i = 0; i < m_windowsOrder.count(); ++i) { const WId id = m_windowsOrder.at(i); const KWindowInfo info(id, NET::WMDesktop | NET::WMVisibleName | NET::WMWindowType); if (info.windowType(NET::NormalMask | NET::DialogMask | NET::UtilityMask) != -1 && info.isOnCurrentDesktop()) { if (next) { KWindowSystem::forceActiveWindow(id); return; } if (first == 0) { first = id; } if (id == activeWindow) { if (up) { next = true; } else if (last) { KWindowSystem::forceActiveWindow(last); return; } } last = id; } } KWindowSystem::forceActiveWindow(up ? first : last); }
//----------------------------------------------------------------------------- // 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 DesktopSwitch::onWindowChanged(WId id, NET::Properties properties, NET::Properties2 properties2) { if (properties.testFlag(NET::WMState) && isWindowHighlightable(id)) { KWindowInfo info = KWindowInfo(id, NET::WMDesktop | NET::WMState); int desktop = info.desktop(); if (!info.valid() || info.onAllDesktops()) return; else { DesktopSwitchButton *button = static_cast<DesktopSwitchButton *>(m_buttons->button(desktop - 1)); if(button) button->setUrgencyHint(id, info.hasState(NET::DemandsAttention)); } } }
void Task::setMaximized(bool maximize) { KWindowInfo info = KWindowSystem::windowInfo(d->win, NET::WMState | NET::XAWMState | NET::WMDesktop); bool on_current = info.isOnCurrentDesktop(); if (!on_current) { KWindowSystem::setCurrentDesktop(info.desktop()); } if (info.isMinimized()) { KWindowSystem::unminimizeWindow(d->win); } if (!on_current) { KWindowSystem::forceActiveWindow(d->win); } }
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; }
void GraphicalUi::activateMainWidget() { #ifdef HAVE_KDE4 # ifdef Q_WS_X11 KWindowInfo info = KWindowSystem::windowInfo(mainWidget()->winId(), NET::WMDesktop | NET::WMFrameExtents); if (_onAllDesktops) { KWindowSystem::setOnAllDesktops(mainWidget()->winId(), true); } else { KWindowSystem::setCurrentDesktop(info.desktop()); } mainWidget()->move(info.frameGeometry().topLeft()); // avoid placement policies mainWidget()->show(); mainWidget()->raise(); KWindowSystem::raiseWindow(mainWidget()->winId()); KWindowSystem::activateWindow(mainWidget()->winId()); # else mainWidget()->show(); KWindowSystem::raiseWindow(mainWidget()->winId()); KWindowSystem::forceActiveWindow(mainWidget()->winId()); # endif #else /* HAVE_KDE4 */ #ifdef Q_WS_X11 // Bypass focus stealing prevention QX11Info::setAppUserTime(QX11Info::appTime()); #endif if (mainWidget()->windowState() & Qt::WindowMinimized) { // restore mainWidget()->setWindowState((mainWidget()->windowState() & ~Qt::WindowMinimized) | Qt::WindowActive); } // this does not actually work on all platforms... and causes more evil than good // mainWidget()->move(mainWidget()->frameGeometry().topLeft()); // avoid placement policies mainWidget()->show(); mainWidget()->raise(); mainWidget()->activateWindow(); #endif /* HAVE_KDE4 */ }
//----------------------------------------------------------------------------- // Toggle Shade task //FIXME void daisy::toggShadeTask(WId id) { KWindowInfo taskInfo = KWindowSystem::windowInfo( id, NET::WMState, NET::WM2WindowClass ); if ( taskInfo.valid() ) { if ( taskInfo.hasState( NET::Shaded ) ) { KWindowSystem::clearState( id, NET::Shaded ); KWindowSystem::unminimizeWindow( id, true ); // KWindowSystem::activateWindow( id ); } else { KWindowSystem::setState( id, NET::Shaded ); // KWindowSystem::setState( id, NET::DemandsAttention );//FOR TESTING, COMMENT AFTER } } }
//----------------------------------------------------------------------------- // Toggle task //FIXME void daisy::toggTask(WId id) { KWindowInfo taskInfo = KWindowSystem::windowInfo( id, NET::WMState, NET::WM2WindowClass ); if ( taskInfo.valid() ) { //HACK widget gains focus on click FIXME if ( !taskInfo.isMinimized() && ( m_actwin_save == id ) ) {KWindowSystem::minimizeWindow( id, true );} else { KWindowSystem::unminimizeWindow( id, true ); KWindowSystem::activateWindow( id ); } m_up_tmr->stop();m_up_tmr->setInterval(10);m_up_tmr->start(); } }
KlipperPopup::KlipperPopup( History* history ) : m_dirty( true ), m_textForEmptyHistory( i18n( "<empty clipboard>" ) ), m_textForNoMatch( i18n( "<no matches>" ) ), m_history( history ), m_helpMenu( new KHelpMenu( this, Klipper::aboutData(), false ) ), m_popupProxy( 0 ), m_filterWidget( 0 ), m_filterWidgetAction( 0 ), m_nHistoryItems( 0 ) { KWindowInfo windowInfo = KWindowSystem::windowInfo( winId(), NET::WMGeometry ); QRect geometry = windowInfo.geometry(); QRect screen = KGlobalSettings::desktopGeometry(geometry.center()); int menuHeight = ( screen.height() ) * 3/4; int menuWidth = ( screen.width() ) * 1/3; m_popupProxy = new PopupProxy( this, menuHeight, menuWidth ); connect( this, SIGNAL(aboutToShow()), SLOT(slotAboutToShow()) ); }
//----------------------------------------------------------------------------- // 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; }
//----------------------------------------------------------------------------- // ATTENTION void daisy::checkAttention( KWindowInfo taskInfo, QString widclass_tmp ) { if ( taskInfo.hasState( NET::DemandsAttention ) && !m_attentionwindow.contains( m_alias.indexOf( widclass_tmp )) ) { m_attentionwindow << m_alias.indexOf( widclass_tmp ); } else if ( m_attentionwindow.contains( m_alias.indexOf( widclass_tmp )) ) { m_attentionwindow.removeAt(m_attentionwindow.indexOf( m_alias.indexOf( widclass_tmp )) ); } }
//----------------------------------------------------------------------------- // 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(); }
//----------------------------------------------------------------------------- // 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 WindowList::showMenu(bool onlyCurrentDesktop) { QList<WId> windows = KWindowSystem::windows(); QList<QAction*> actionList; QList< QList<QAction*> > windowList; int amount = 0; int number = 0; qDeleteAll(m_listMenu->actions()); //m_listMenu->clear(); if (!onlyCurrentDesktop) { m_listMenu->addTitle(i18n("Actions")); QAction *unclutterAction = m_listMenu->addAction(i18n("Unclutter Windows")); QAction *cascadeAction = m_listMenu->addAction(i18n("Cascade Windows")); connect(unclutterAction, SIGNAL(triggered()), m_listMenu, SLOT(slotUnclutterWindows())); connect(cascadeAction, SIGNAL(triggered()), m_listMenu, SLOT(slotCascadeWindows())); } for (int i = 0; i <= KWindowSystem::numberOfDesktops(); ++i) { windowList.append(QList<QAction*>()); } for (int i = 0; i < windows.count(); ++i) { KWindowInfo window = KWindowSystem::windowInfo(windows.at(i), (NET::WMGeometry | NET::WMFrameExtents | NET::WMWindowType | NET::WMDesktop | NET::WMState | NET::XAWMState | NET::WMVisibleName)); NET::WindowType type = window.windowType(NET::NormalMask | NET::DialogMask | NET::OverrideMask | NET::UtilityMask | NET::DesktopMask | NET::DockMask | NET::TopMenuMask | NET::SplashMask | NET::ToolbarMask | NET::MenuMask); if ((onlyCurrentDesktop && !window.isOnDesktop(KWindowSystem::currentDesktop())) || type == NET::Desktop || type == NET::Dock || type == NET::TopMenu || type == NET::Splash || type == NET::Menu || type == NET::Toolbar || window.hasState(NET::SkipPager)) { windows.removeAt(i); --i; continue; } ++amount; QAction *action = new QAction(QIcon(KWindowSystem::icon(windows.at(i))), window.visibleName(), this); action->setData((unsigned long long) windows.at(i)); QString window_title = QString(action->text()); window_title.truncate(55); action->setText(window_title); QFont font = QFont(action->font()); if (window.isMinimized()) { font.setItalic(true); } else if (KWindowSystem::activeWindow() == windows.at(i)) { font.setUnderline(true); font.setBold(true); } action->setFont(font); number = ((onlyCurrentDesktop || window.onAllDesktops()) ? 0 : window.desktop()); QList<QAction*> subList = windowList.value(number); subList.append(action); windowList.replace(number, subList); } const bool useSubMenus = (!onlyCurrentDesktop && KWindowSystem::numberOfDesktops() > 1 && (amount / KWindowSystem::numberOfDesktops()) > 5); if (amount && useSubMenus) { m_listMenu->addTitle(i18n("Desktops")); } for (int i = 0; i <= KWindowSystem::numberOfDesktops(); ++i) { if (windowList.value(i).isEmpty()) { continue; } KMenu *subMenu = NULL; QAction *subMenuAction = NULL; QString title = (i ? KWindowSystem::desktopName(i) : (onlyCurrentDesktop ? i18n("Current desktop") : i18n("On all desktops"))); if (useSubMenus) { subMenuAction = m_listMenu->addAction(title); subMenu = new KMenu(m_listMenu); subMenu->installEventFilter(this); } else { m_listMenu->addTitle(title); } for (int j = 0; j < windowList.value(i).count(); ++j) { if (useSubMenus) { subMenu->addAction(windowList.value(i).value(j)); } else { m_listMenu->addAction(windowList.value(i).value(j)); } } if (useSubMenus) { subMenuAction->setMenu(subMenu); } } if (!amount) { qDeleteAll(m_listMenu->actions()); m_listMenu->clear(); QAction *noWindows = m_listMenu->addAction(i18n("No windows")); noWindows->setEnabled(false); } if (formFactor() == Plasma::Vertical || formFactor() == Plasma::Horizontal) { m_listMenu->popup(popupPosition(m_listMenu->sizeHint())); } else { m_listMenu->popup(QCursor::pos()); } }
void KWD::Decorator::handleWindowAdded (WId id) { QMap <WId, KWD::Window *>::ConstIterator it; KWD::Window *client = 0; WId select, frame = 0; WId oframe = 0, iframe = 0; KWD::Window::Type type = KWD::Window::Normal; QWidgetList widgets; QRect geometry; /* avoid adding any of our own top level windows */ foreach (QWidget *widget, QApplication::topLevelWidgets ()) { if (widget->winId () == id) return; } if (KWD::readWindowProperty (id, Atoms::switchSelectWindow, (long *) &select)) { if (!mSwitcher) mSwitcher = new Switcher (mCompositeWindow, id); if (mSwitcher->xid () != id) { delete mSwitcher; mSwitcher = new Switcher (mCompositeWindow, id); } geometry = mSwitcher->geometry (); frame = None; } else { KWindowInfo wInfo; KWD::trapXError (); wInfo = KWindowSystem::windowInfo (id, NET::WMGeometry); if (KWD::popXError ()) return; if (!wInfo.valid ()) return; KWD::readWindowProperty (id, Atoms::netInputFrameWindow, (long *) &iframe); KWD::readWindowProperty (id, Atoms::netOutputFrameWindow, (long *) &oframe); geometry = wInfo.geometry (); wInfo = KWindowSystem::windowInfo (id, NET::WMWindowType, 0); switch (wInfo.windowType (~0)) { case NET::Normal: case NET::Dialog: case NET::Toolbar: case NET::Menu: case NET::Utility: case NET::Splash: case NET::Unknown: /* decorate these window types */ break; default: return; } if (iframe) { type = KWD::Window::Normal; frame = iframe; } else { type = KWD::Window::Normal2D; frame = oframe; } } KWD::trapXError (); XSelectInput (QX11Info::display (), id, StructureNotifyMask | PropertyChangeMask); KWD::popXError (); if (frame) { XWindowAttributes attr; KWD::trapXError (); XGetWindowAttributes (QX11Info::display (), frame, &attr); if (KWD::popXError ()) frame = None; } if (frame) { if (!mClients.contains (id)) { client = new KWD::Window (mCompositeWindow, id, frame, type, geometry); mClients.insert (id, client); mFrames.insert (frame, client); } else { client = mClients[id]; mFrames.remove (client->frameId ()); mFrames.insert (frame, client); client->updateFrame (frame); } if (mWindowsMenu.removeOne (id)) mClients[id]->setAppMenuAvailable (); } else { if (mClients.contains (id)) client = mClients[id]; if (client) { mClients.remove (client->windowId ()); mFrames.remove (client->frameId ()); delete client; } } }
//----------------------------------------------------------------------------- // 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(); } } } }
//----------------------------------------------------------------------------- // 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; }