示例#1
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));
        }
    }
}
示例#2
0
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);
    }
}
示例#3
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(), "#"));
}
示例#4
0
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 */
}
示例#5
0
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());
    }
}
示例#6
0
//-----------------------------------------------------------------------------
// 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;
}
示例#7
0
//-----------------------------------------------------------------------------
// 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();
      }
    }
  
    
    
  }

  
}