Esempio n. 1
0
void Task::addItem(AbstractGroupableItem *abstractItem)
{
    if (abstractItem->itemType() != TaskManager::GroupItemType)
    {
        TaskItem *task = qobject_cast<TaskItem*>(abstractItem);

        if (task->task())
        {
            emit windowAdded(task->task()->window());
        }
    }

    emit changed(WindowsChanged);
}
Esempio n. 2
0
void LipstickCompositor::surfaceMapped()
{
    QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(sender());
    //Ignore surface if it's not a window surface
    if (!surface->hasShellSurface())
        return;

    QVariantMap properties = surface->windowProperties();
    QString category = properties.value("CATEGORY").toString();

    if (surface->surfaceItem()) {
        // Always cause a repaint on surface mapped
        maybePostUpdateRequest();
        return;
    }

    // The surface was mapped for the first time
    int id = m_nextWindowId++;
    LipstickCompositorWindow *item = new LipstickCompositorWindow(id, category, surface, contentItem());
    item->setSize(surface->size());
    QObject::connect(item, SIGNAL(destroyed(QObject*)), this, SLOT(windowDestroyed()));

    // Whenever the item is damaged, cause a full repaint
    QObject::connect(item, SIGNAL(textureChanged()), this, SLOT(maybePostUpdateRequest()));
    m_totalWindowCount++;
    m_mappedSurfaces.insert(id, item);

    item->setTouchEventsEnabled(true);

    emit windowCountChanged();
    emit windowAdded(item);

    windowAdded(id);

    emit availableWinIdsChanged();
}
Esempio n. 3
0
void WindowsManager::addWindow(Window *window, OpenHints hints)
{
	if (!window)
	{
		return;
	}

	int index = ((!(hints & EndOpen) && SettingsManager::getValue(QLatin1String("TabBar/OpenNextToActive")).toBool()) ? (m_tabBar->currentIndex() + 1) : m_tabBar->count());

	if (!window->isPinned())
	{
		const int offset = m_tabBar->getPinnedTabsAmount();

		if (index < offset)
		{
			index = offset;
		}
	}

	m_tabBar->addTab(index, window);

	m_mdi->addWindow(window);

	if (!(hints & BackgroundOpen))
	{
		m_tabBar->setCurrentIndex(index);

		if (m_isRestored)
		{
			setActiveWindow(index);
		}
	}

	connect(window, SIGNAL(titleChanged(QString)), this, SLOT(setTitle(QString)));
	connect(window, SIGNAL(requestedOpenUrl(QUrl,OpenHints)), this, SLOT(open(QUrl,OpenHints)));
	connect(window, SIGNAL(requestedOpenBookmark(BookmarksItem*,OpenHints)), this, SLOT(open(BookmarksItem*,OpenHints)));
	connect(window, SIGNAL(requestedSearch(QString,QString,OpenHints)), this, SLOT(search(QString,QString,OpenHints)));
	connect(window, SIGNAL(requestedAddBookmark(QUrl,QString)), this, SIGNAL(requestedAddBookmark(QUrl,QString)));
	connect(window, SIGNAL(requestedNewWindow(ContentsWidget*,OpenHints)), this, SLOT(openWindow(ContentsWidget*,OpenHints)));
	connect(window, SIGNAL(requestedCloseWindow(Window*)), this, SLOT(closeWindow(Window*)));

	emit windowAdded(index);
}
Esempio n. 4
0
void Compositor::windowIsReady()
{
    CompositorWindow *window = static_cast<CompositorWindow*>(sender());
    QWaylandXdgSurface *pShellSurfaceExt = static_cast<QWaylandXdgSurface*>(window->shellSurface());

    QWaylandXdgToplevel *pXdgTopLevel = NULL;
    if(pShellSurfaceExt) pXdgTopLevel = pShellSurfaceExt->toplevel();

    // Windows created by QtWebProcess are not meant to be shown to the user
    // They are mainly temporary windows used for offscreen drawing.
    // Therefore, as long as they are hidden, don't create a card for them.
    if (pXdgTopLevel->appId() != "QtWebProcess" && pXdgTopLevel->appId() != "QtWebEngineProcess") {
        if (!WindowModel::isWindowAlreadyAdded(mWindowModels, window)) {
            qDebug() << Q_FUNC_INFO << "Adding window" << window << "to our models";
            emit windowAdded(QVariant::fromValue(static_cast<QQuickItem*>(window)));
            WindowModel::addWindowForEachModel(mWindowModels, window);
        }
    }
}
Esempio n. 5
0
        void createConnections()
        {
#ifdef Q_WS_X11
            // d == NULL means "disabled"
            if( !KApplication::kApplication())
                return;
            if( !QX11Info::display())
                return;

            if( !( flags & DisableKWinModule )) {
                QObject::connect( KWindowSystem::self(), SIGNAL( windowAdded( WId )), q, SLOT( slot_window_added( WId )));
#ifdef __GNUC__
#warning "systemTrayWindowAdded signal was remove from KWindowSystem class"
#endif		
                //QObject::connect( KWindowSystem::self(), SIGNAL( systemTrayWindowAdded( WId )), q, SLOT( slot_window_added( WId )));
            }
            QObject::connect( &msgs, SIGNAL( gotMessage( const QString& )), q, SLOT( got_message( const QString& )));
            cleanup = new QTimer( q );
            QObject::connect( cleanup, SIGNAL( timeout()), q, SLOT( startups_cleanup()));
#endif
        }
Esempio n. 6
0
void SystemCompositor::surfaceMapped()
{
    QWaylandSurface *surface = qobject_cast<QWaylandSurface *>(sender());

    //A surface without a shell surface is not a window
    if (!surface->hasShellSurface())
        return;

    QWaylandSurfaceItem *item = surface->surfaceItem();

    // Create a QWaylandSurfaceItem from the surface
    if (!item) {
        item = new QWaylandSurfaceItem(surface, rootObject());
        item->setClientRenderingEnabled(true);
        item->setTouchEventsEnabled(true);
    }

    // Surface items gain focus right after they were mapped
    item->takeFocus();

    // Announce a window was added
    emit windowAdded(QVariant::fromValue(static_cast<QQuickItem *>(item)));
}
WindowListModel::WindowListModel( WId kdevWinId, QObject* parent):
    QAbstractListModel(parent),
    m_kdevWinId(kdevWinId)
{
    KWindowSystem *kws = KWindowSystem::self();
    
//     QList<WId> winList = kws->windows();
//     
//     QList<WId>::ConstIterator it;
//     QList<WId>::ConstIterator end = KWindowSystem::windows().end();
//     for ( it = KWindowSystem::windows().begin(); it != end; ++it )
//     {
//         KWindowInfo kwi = kws->windowInfo(*it, NET::WMName | NET::WMVisibleName | NET::WMVisibleIconName | NET::WMWindowType);
//         
//         if( kwi.windowType(NET::NormalMask) == NET::Normal ) {
//             m_winList.append( kwi );
// //             qDebug() << "Adding window " << kwi.visibleName() << "(" << kwi.win() << ")";
//         }
//     }
    
    connect( kws, SIGNAL(windowAdded(WId)), this, SLOT(onWindowAdded(WId)));
    connect( kws, SIGNAL(windowRemoved(WId)), this, SLOT(onWindowRemoved(WId)));
    connect( kws, SIGNAL(windowChanged(WId,uint)), this, SLOT(onWindowChanged(WId,uint)) );
}
Esempio n. 8
0
void TaskManager::windowChanged(WId w, unsigned int dirty)
{
    if( dirty & NET::WMState ) {
        NETWinInfo info ( qt_xdisplay(),  w, qt_xrootwin(), NET::WMState );
        if ( (info.state() & NET::SkipTaskbar) != 0 ) {
            windowRemoved( w );
            _skiptaskbar_windows.push_front( w );
            return;
        }
        else {
            _skiptaskbar_windows.remove( w );
            if( !findTask( w ))
                windowAdded( w ); // skipTaskBar state was removed, so add this window
        }
    }

    // check if any state we are interested in is marked dirty
    if(!(dirty & (NET::WMVisibleName|NET::WMName|NET::WMState|NET::WMIcon|NET::XAWMState|NET::WMDesktop)) )
        return;

    // find task
    Task* t = findTask( w );
    if (!t) return;

    //kdDebug() << "TaskManager::windowChanged " << w << " " << dirty << endl;


    // refresh icon pixmap if necessary
    if (dirty & NET::WMIcon)
        t->refresh(true);
    else
        t->refresh();

    if(dirty & (NET::WMDesktop|NET::WMState|NET::XAWMState))
        emit windowChanged(w); // moved to different desktop or is on all or change in iconification/withdrawnnes
}
Esempio n. 9
0
bool
KWD::Decorator::enableDecorations (Time timestamp)
{
    QList <WId>::ConstIterator it;
    unsigned int nchildren;
    WId       *children;
    WId       root, parent;
    long int  select;

    mDmSnTimestamp = timestamp;

    if (!pluginManager ()->loadPlugin (""))
	return false;

    updateAllShadowOptions ();

    KWD::trapXError ();
    (void) QApplication::desktop (); // trigger creation of desktop widget
    KWD::popXError ();

    updateShadow ();

    /* FIXME: Implement proper decoration lists and remove this */
    mDecorNormal = new KWD::Window (mCompositeWindow,
                                    QX11Info::appRootWindow (),
                                    0, Window::Default);
    mDecorActive = new KWD::Window (mCompositeWindow,
				    QX11Info::appRootWindow (),
				    0, Window::DefaultActive);

    mActiveId = KWindowSystem::activeWindow ();

    connect (KWindowSystem::self (), SIGNAL (windowAdded (WId)),
	     SLOT (handleWindowAdded (WId)));
    connect (KWindowSystem::self (), SIGNAL (windowRemoved (WId)),
	     SLOT (handleWindowRemoved (WId)));
    connect (KWindowSystem::self (), SIGNAL (activeWindowChanged (WId)),
	     SLOT (handleActiveWindowChanged (WId)));
    connect (KWindowSystem::self (),
	     SIGNAL (windowChanged (WId, const unsigned long *)),
	     SLOT (handleWindowChanged (WId, const unsigned long *)));

    foreach (WId id, KWindowSystem::windows ())
	handleWindowAdded (id);

    /* Find the switcher and add it too
     * FIXME: Doing XQueryTree and then
     * XGetWindowProperty on every window
     * like this is really expensive, surely
     * there is a better way to do this */

    XQueryTree (QX11Info::display (), QX11Info::appRootWindow (),
                &root, &parent, &children, &nchildren);

    for (unsigned int i = 0; i < nchildren; i++)
    {
        if (KWD::readWindowProperty (children[i],
                                     Atoms::switchSelectWindow, &select))
        {
            handleWindowAdded(children[i]);
            break;
        }
    }

    connect (Plasma::Theme::defaultTheme (), SIGNAL (themeChanged ()),
	     SLOT (plasmaThemeChanged ()));

    // select for client messages
    XSelectInput (QX11Info::display (), QX11Info::appRootWindow (),
                  SubstructureNotifyMask |
                  StructureNotifyMask |
                  PropertyChangeMask);

    return true;
}
Esempio n. 10
0
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);
}
Esempio n. 11
0
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);
}
Esempio n. 12
0
void WindowsManager::addWindow(Window *window, OpenHints hints, int index, const QRect &geometry, WindowState state, bool isAlwaysOnTop)
{
	if (!window)
	{
		return;
	}

	m_windows[window->getIdentifier()] = window;

	if (window->isPrivate())
	{
		m_mainWindow->getAction(ActionsManager::ClosePrivateTabsAction)->setEnabled(true);
	}

	window->setControlsHidden(m_mainWindow->isFullScreen());

	if (index < 0)
	{
		index = ((!hints.testFlag(EndOpen) && SettingsManager::getValue(QLatin1String("TabBar/OpenNextToActive")).toBool()) ? (m_mainWindow->getTabBar()->currentIndex() + 1) : m_mainWindow->getTabBar()->count());
	}

	if (!window->isPinned())
	{
		const int offset = m_mainWindow->getTabBar()->getPinnedTabsAmount();

		if (index < offset)
		{
			index = offset;
		}
	}

	const QString newTabOpeningAction = SettingsManager::getValue(QLatin1String("Interface/NewTabOpeningAction")).toString();

	if (m_isRestored && newTabOpeningAction == QLatin1String("maximizeTab"))
	{
		state = MaximizedWindowState;
	}

	m_mainWindow->getTabBar()->addTab(index, window);
	m_mainWindow->getWorkspace()->addWindow(window, geometry, state, isAlwaysOnTop);

	if (!m_mainWindow->getAction(ActionsManager::CloseTabAction)->isEnabled())
	{
		m_mainWindow->getAction(ActionsManager::CloseTabAction)->setEnabled(true);
	}

	if (!hints.testFlag(BackgroundOpen) || m_mainWindow->getTabBar()->count() < 2)
	{
		m_mainWindow->getTabBar()->setCurrentIndex(index);

		if (m_isRestored)
		{
			setActiveWindowByIndex(index);
		}
	}

	if (m_isRestored)
	{
		if (newTabOpeningAction == QLatin1String("cascadeAll"))
		{
			ActionsManager::triggerAction(ActionsManager::CascadeAllAction, this);
		}
		else if (newTabOpeningAction == QLatin1String("tileAll"))
		{
			ActionsManager::triggerAction(ActionsManager::TileAllAction, this);
		}
	}

	connect(m_mainWindow, SIGNAL(controlsHiddenChanged(bool)), window, SLOT(setControlsHidden(bool)));
	connect(window, SIGNAL(titleChanged(QString)), this, SLOT(setTitle(QString)));
	connect(window, SIGNAL(requestedOpenUrl(QUrl,WindowsManager::OpenHints)), this, SLOT(open(QUrl,WindowsManager::OpenHints)));
	connect(window, SIGNAL(requestedOpenBookmark(BookmarksItem*,WindowsManager::OpenHints)), this, SLOT(open(BookmarksItem*,WindowsManager::OpenHints)));
	connect(window, SIGNAL(requestedSearch(QString,QString,WindowsManager::OpenHints)), this, SLOT(search(QString,QString,WindowsManager::OpenHints)));
	connect(window, SIGNAL(requestedAddBookmark(QUrl,QString,QString)), this, SIGNAL(requestedAddBookmark(QUrl,QString,QString)));
	connect(window, SIGNAL(requestedEditBookmark(QUrl)), this, SIGNAL(requestedEditBookmark(QUrl)));
	connect(window, SIGNAL(requestedNewWindow(ContentsWidget*,WindowsManager::OpenHints)), this, SLOT(openWindow(ContentsWidget*,WindowsManager::OpenHints)));
	connect(window, SIGNAL(requestedCloseWindow(Window*)), this, SLOT(handleWindowClose(Window*)));

	emit windowAdded(window->getIdentifier());
}