Пример #1
0
bool RazorTaskButton::isApplicationActive() const
{
    return xfitMan().getActiveAppWindow() == mWindow;
}
Пример #2
0
void RazorTaskButton::nextCheckState()
{
    setChecked(xfitMan().getActiveAppWindow() == mWindow);
}
Пример #3
0
bool RazorTaskButton::isAppHidden() const
{
    return xfitMan().isHidden(mWindow);
}
Пример #4
0
void RazorPanel::show()
{
    QWidget::show();
    xfitMan().moveWindowToDesktop(this->effectiveWinId(), -1);
}
Пример #5
0
void RazorWorkSpaceManager::setup()
{
    m_config->sync();
    m_config->beginGroup(DesktopConfig::instance()->configId);
    
    bool useDifferentWallpapers = m_config->value("use_different_wallpapers", false).toBool();

    QMap< int,QMap<int,WorkspaceConfig> > desktops;

    WorkspaceConfig defaults(
                            strToBackgroundType(m_config->value("wallpaper_type", "color").toString(), RazorWorkSpaceManager::BackgroundColor),
                            false,
                            m_config->value("wallpaper", "#006600").toString()
                        );

    // important: here is used screenCount() instead of beginReadArray()
    // QSettings can contain more/les/or none desktop defined.
    m_config->beginReadArray("screens");
    int numScreens = QApplication::desktop()->screenCount();

    // Loop over screens
    QString themeWallpaper;
    for (int screen = 0; screen < numScreens; ++screen)
    {
       m_config->setArrayIndex(screen);
       m_config->beginReadArray("desktops");

       // Loop over virtual desktops
       for (int desktop = 0; desktop < m_desktopCount; ++desktop)
       {
           if (!useDifferentWallpapers && desktop > 0)
               break;

           m_config->setArrayIndex(desktop);
           themeWallpaper = razorTheme.desktopBackground(desktop + 1);

           desktops[screen][desktop] = WorkspaceConfig (
                               strToBackgroundType(m_config->value("wallpaper_type", themeWallpaper.isEmpty() ? "color" : "pixmap").toString(), RazorWorkSpaceManager::BackgroundColor),
                               m_config->value("keep_aspect_ratio", defaults.keepAspectRatio).toBool(),
                               m_config->value("wallpaper", themeWallpaper.isEmpty() ? defaults.wallpaper : themeWallpaper).toString()
                           );
        }

        m_config->endArray();  // desktops
    }
    m_config->endArray();  // screens
     
    m_config->endGroup();
     
    // Remove workspaces of additional screens
    int toRemove = m_workspaces.count() - numScreens;
    for (int i = 0; i < toRemove; ++i)
    {
        qDeleteAll(m_workspaces.last());
        m_workspaces.removeLast();
    }

    // Loop over screens
    for (int screen = 0; screen < numScreens; ++screen)
    {
        QList<RazorWorkSpace*> screenWorkspaces;
        if (screen < m_workspaces.count())
        {
            // Existing screen
            screenWorkspaces = m_workspaces[screen];
        }
        else
        {
            // New screen
            Q_ASSERT(screen == m_workspaces.count());
            m_workspaces.append(QList<RazorWorkSpace*>());
            screenWorkspaces = m_workspaces.last();
        }

        // Remove additional workspaces
        int toRemove = screenWorkspaces.count() - m_desktopCount;
        for (int i = 0; i < toRemove; ++i)
            delete screenWorkspaces.takeLast();

        // Loop over virtual desktops
        for (int desktop = 0; desktop < m_desktopCount; ++desktop)
        {
            if (!useDifferentWallpapers && desktop > 0)
                break;

//            qDebug() << "workspace screen: " << screen;
//            qDebug() << "virtual desktop: " << desktop;

            // Use existing RazorWorkSpace instance or create a new one
            RazorWorkSpace * ws;
            if (desktop < screenWorkspaces.count())
            {
                // Existing workspace
                ws = screenWorkspaces.at(desktop);
            }
            else
            {
                // New workspace
                Q_ASSERT(desktop == screenWorkspaces.count());
                ws = new RazorWorkSpace(m_scene, screen, desktop);
                connect(m_scene, SIGNAL(saveConfig()), ws, SLOT(saveConfig()));
                m_workspaces[screen].append(ws);
            }

            if (desktops.contains(screen) && desktops[screen].contains(desktop))
                ws->setConfig(desktops.value(screen).value(desktop));
            else
                ws->setConfig(defaults);
            
            ws->show();
            
            // This X11 call seems mandatory for issue #3:
            // "There is only one desktop when on plasma-desktop"
            // for some WM it is not enough to use Qt::WA_X11NetWmWindowTypeDesktop
            // Note: this has to be called after is ws shown to take an effect.
            // EWMH specs: Cardinal to determine the desktop the window is in (or wants to be) starting with 0 for the first desktop. A Client MAY choose not to set this property, in which case the Window Manager SHOULD place it as it wishes. 0xFFFFFFFF indicates that the window SHOULD appear on all desktops.
            if (useDifferentWallpapers)
                xfitMan().moveWindowToDesktop(ws->winId(), desktop);
            else
                xfitMan().moveWindowToDesktop(ws->winId(), 0xFFFFFFFF);
        }
    }
}
Пример #6
0
bool TrayIcon::init()
{
    Display* dsp = QX11Info::display();

    XWindowAttributes attr;
    if (! XGetWindowAttributes(dsp, mIconId, &attr)) return false;

//    qDebug() << "New tray icon ***********************************";
//    qDebug() << "  * window id:  " << hex << mIconId;
//    qDebug() << "  * window name:" << xfitMan().getName(mIconId);
//    qDebug() << "  * size (WxH): " << attr.width << "x" << attr.height;
//    qDebug() << "  * color depth:" << attr.depth;

    unsigned long mask = 0;
    XSetWindowAttributes set_attr;

    Visual* visual = attr.visual;
    set_attr.colormap = attr.colormap;
    set_attr.background_pixel = 0;
    set_attr.border_pixel = 0;
    mask = CWColormap|CWBackPixel|CWBorderPixel;

    mWindowId = XCreateWindow(dsp, this->winId(), 0, 0, mIconSize.width(), mIconSize.height(),
                              0, attr.depth, InputOutput, visual, mask, &set_attr);


    xError = false;
    XErrorHandler old;
    old = XSetErrorHandler(windowErrorHandler);
    XReparentWindow(dsp, mIconId, mWindowId, 0, 0);
    XSync(dsp, false);
    XSetErrorHandler(old);

    if (xError) {
        qWarning() << "****************************************";
        qWarning() << "* Not icon_swallow                     *";
        qWarning() << "****************************************";
        XDestroyWindow(dsp, mWindowId);
        return false;
    }


    {
        Atom acttype;
        int actfmt;
        unsigned long nbitem, bytes;
        unsigned char *data = 0;
        int ret;

        ret = XGetWindowProperty(dsp, mIconId, xfitMan().atom("_XEMBED_INFO"),
                                 0, 2, false, xfitMan().atom("_XEMBED_INFO"),
                                 &acttype, &actfmt, &nbitem, &bytes, &data);
        if (ret == Success) {
            if (data)
                XFree(data);
        }
        else {
            qWarning() << "TrayIcon: xembed error";
            XDestroyWindow(dsp, mWindowId);
            return false;
        }
    }

    {
        XEvent e;
        e.xclient.type = ClientMessage;
        e.xclient.serial = 0;
        e.xclient.send_event = True;
        e.xclient.message_type = xfitMan().atom("_XEMBED");
        e.xclient.window = mIconId;
        e.xclient.format = 32;
        e.xclient.data.l[0] = CurrentTime;
        e.xclient.data.l[1] = XEMBED_EMBEDDED_NOTIFY;
        e.xclient.data.l[2] = 0;
        e.xclient.data.l[3] = mWindowId;
        e.xclient.data.l[4] = 0;
        XSendEvent(dsp, mIconId, false, 0xFFFFFF, &e);
    }

    XSelectInput(dsp, mIconId, StructureNotifyMask);
    mDamage = XDamageCreate(dsp, mIconId, XDamageReportRawRectangles);
    XCompositeRedirectWindow(dsp, mWindowId, CompositeRedirectManual);

    XMapWindow(dsp, mIconId);
    XMapRaised(dsp, mWindowId);

    xfitMan().resizeWindow(mWindowId, mIconSize.width(), mIconSize.height());
    xfitMan().resizeWindow(mIconId,   mIconSize.width(), mIconSize.height());

    return true;
}
Пример #7
0
subway_panel::subway_panel(int len, int hei, subway_panel::position_T pos, QString name): QFrame()
{
    desktop = QApplication::desktop();
    this->setWindowFlags(Qt::FramelessWindowHint|Qt::Window|Qt::WindowStaysOnTopHint);
    position = pos;
    switch(pos)
    {
	case top:
	case bottom:
	if(len == 0)
	{
	    length = desktop->width();
	}
	else length = len;
	this->setMinimumWidth(length);
	this->setMaximumWidth(length);
	weight = hei;
	this->setMaximumHeight(weight);
	this->setMinimumHeight(weight);
	layout = new QBoxLayout(QBoxLayout::LeftToRight,this);
	((QBoxLayout*)layout)->setAlignment(Qt::AlignLeft);
	((QBoxLayout*)layout)->setSpacing(0);
	((QBoxLayout*)layout)->setMargin(0);
	((QBoxLayout*)layout)->setContentsMargins(0,0,0,0);
	break;
    }
    switch(pos)
    {
	case top:
	  setScreenPos(QPoint(0,0));
	  break;
	case bottom:
	  setScreenPos(QPoint(0,desktop->height()-weight));
	  break;
	case left:
	case right:
	  break;
    }
    settings = new QSettings("Subway","Panel-" + name + "-Applets");
    if(settings->value("initialized","").toString() == "")
    {
	//Initialize new panel
	settings->setValue("initialized","y");
	settings->setValue("appletnum",1);
	settings->setValue("applet1","window-list");
	settings->setValue("applet1-height",32);
	settings->setValue("applet1-width",32);
	//settings->setValue("applet1-align","left");
    }
    this->setLayout(layout);
    for(int i = 1;i<=settings->value("appletnum").toInt();i++)
    {
	QString applet_setting_name = QString("applet")+QVariant(i).toString();
	QString name = settings->value(applet_setting_name).toString();
	QWidget *applet;
	if(name == "window-list")
	{
	    applet = new window_list(this);
	}
	else
	{
	    applet = new QWidget(this);
	}
	int tmp;
	if((tmp = settings->value(applet_setting_name+"-height").toInt()) != 0)
	{
	    applet->setMinimumHeight(tmp);
	    applet->setMaximumHeight(tmp);
	}
	else
	{
	    QSizePolicy sp = applet->sizePolicy();
	    sp.setVerticalPolicy(QSizePolicy::Expanding);
	    applet->setSizePolicy(sp);
	}
	if((tmp = settings->value(applet_setting_name+"-width").toInt()) != 0)
	{
	    applet->setMaximumWidth(tmp);
	    applet->setMinimumWidth(tmp);
	}
	else
	{
	    QSizePolicy sp = applet->sizePolicy();
	    sp.setHorizontalPolicy(QSizePolicy::Expanding);
	    applet->setSizePolicy(sp);
	}
	//layout->addWidget(applet);
	layout->insertWidget(layout->count(),applet);
    }
    this->setAttribute(Qt::WA_X11NetWmWindowTypeDock);
    display = this->x11Info().display();
    XfitMan fitman = xfitMan();
    switch(pos)
    {
      case bottom:
	fitman.setStrut(winId(),  0, 0, 0, weight,
               /* Left   */   0, 0,
               /* Right  */   0, 0,
               /* Top    */   0, 0,
               /* Bottom */   0, desktop->width()
                         );
	break;
      case top:
	fitman.setStrut(winId(),  0, 0, weight, 0,
               /* Left   */   0, 0,
               /* Right  */   0, 0,
               /* Top    */   0, desktop->width(),
               /* Bottom */   0, 0
                         );
    }
}
Пример #8
0
void RazorAppSwitcher::AppSwitcher::handleApps()
{
    qDebug() << "RazorAppSwitcher::AppSwitcher::handleApps()";

    if (m_layout->count())
    {
        QLayoutItem * item;
        while ((item = m_layout->takeAt(0)) != 0)
        {
            item->widget()->hide();
            delete item;
        }
    }
    m_list.clear();

    QList<Window> l = xfitMan().getClientList();
    QList<Window> merge;
    // setup already used windows
    foreach (Window w, m_orderedWindows)
    {
        if (l.contains(w))
        {
            merge.append(w);
            l.removeAll(w);
        }
        else
            m_orderedWindows.removeAll(w);
    }
    // rest at the end
    merge += l;

    // setup new windows
    foreach (Window w, merge)
    {
        if (!xfitMan().acceptWindow(w))
        {
            continue;
        }
        QPixmap pm;
        if (! xfitMan().getClientIcon(w, pm))
            qDebug() << "No icon for:" << w << xfitMan().getName(w);

        SwitcherItem * item = new SwitcherItem(w, xfitMan().getName(w), pm, this);
        connect(item, SIGNAL(infoChanged(const QString&)),
                infoLabel, SLOT(setText(const QString&)));
        connect(item, SIGNAL(activateXWindow()), this, SLOT(activateXWindow()));
        m_list.append(item);
        m_layout->addWidget(item);
    }

    selectNextItem();

    // Warning: show() has to be called *after* setting focus. Dunno why
    // but it works now.
    if (!isVisible())
    {
        QRect desktop = QApplication::desktop()->availableGeometry(xfitMan().getActiveDesktop());
        int x, y;
        x = desktop.width()/2 - width() / 2;
        y = desktop.height()/2 - height() / 2;
        move(x, y);
        show();
    }

}