Exemplo n.º 1
0
void TabSwitcherWidget::showEvent(QShowEvent *event)
{
	setFocus();

	MainWindowSessionItem *mainWindowItem(SessionsManager::getModel()->getMainWindowItem(m_mainWindow));

	if (mainWindowItem)
	{
		const bool useSorting(SettingsManager::getOption(SettingsManager::Interface_TabSwitchingModeOption).toString() != QLatin1String("noSort"));

		for (int i = 0; i < mainWindowItem->rowCount(); ++i)
		{
			WindowSessionItem *windowItem(static_cast<WindowSessionItem*>(mainWindowItem->child(i, 0)));

			if (windowItem)
			{
				m_model->appendRow(createRow(windowItem->getActiveWindow(), (useSorting ? QVariant(windowItem->getActiveWindow()->getLastActivity()) : QVariant(i))));
			}
		}
	}

	m_model->sort(0, ((SettingsManager::getOption(SettingsManager::Interface_TabSwitchingModeOption).toString() == QLatin1String("noSort")) ? Qt::AscendingOrder : Qt::DescendingOrder));

	Window *activeWindow(m_mainWindow->getActiveWindow());
	const int contentsHeight(m_model->rowCount() * 22);

	m_tabsView->setCurrentIndex(m_model->index((activeWindow ? findRow(activeWindow->getIdentifier()) : 0), 0));
	m_tabsView->setMinimumHeight(qMin(contentsHeight, int(height() * 0.9)));

	QWidget::showEvent(event);

	connect(m_mainWindow, SIGNAL(windowAdded(quint64)), this, SLOT(handleWindowAdded(quint64)));
	connect(m_mainWindow, SIGNAL(windowRemoved(quint64)), this, SLOT(handleWindowRemoved(quint64)));
}
Exemplo n.º 2
0
void TabSwitcherWidget::hideEvent(QHideEvent *event)
{
	QWidget::hideEvent(event);

	disconnect(m_mainWindow, SIGNAL(windowAdded(quint64)), this, SLOT(handleWindowAdded(quint64)));
	disconnect(m_mainWindow, SIGNAL(windowRemoved(quint64)), this, SLOT(handleWindowRemoved(quint64)));

	m_model->clear();
}
Exemplo n.º 3
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;
}